Don't ad-block us - support your favorite websites. We have safe, unobstrusive, robotics related ads that you actually want to see - see here for more.
0 Members and 1 Guest are viewing this topic.
Button presses are very simple really. First thing you need are the actual buttons. Which I assume you have selected.Buttons typically have 2 leads coming off of them. One of these you will connect to an open Atmega digital pin. The other will be connected to a 5v source.The button sits between the Atmega and the 5v source, when you push the button, it will connect the Atmega and the 5v source, thus providing the Atmega with a "1"(Digital for ON). If you need more help let me know, I can pull some datasheets and tell you which pins, where, code, etc etc
this may help. this is the pinout for atmega168 but they are the same pinouts.
Buttons typically have 2 leads coming off of them. One of these you will connect to an open Atmega digital pin. The other will be connected to a 5v source.The button sits between the Atmega and the 5v source, when you push the button, it will connect the Atmega and the 5v source, thus providing the Atmega with a "1"(Digital for ON). If you need more help let me know, I can pull some datasheets and tell you which pins, where, code, etc etc
Buttons typically have 2 leads coming off of them. One of these you will connect to an open Atmega digital pin. The other will be connected to a 5v source.The button sits between the Atmega and the 5v source, when you push the button, it will connect the Atmega and the 5v source, thus providing the Atmega with a "1"(Digital for ON).
But I don't understand this 100% (maybe because my mother tongue is not english)
But that doesn't make sense for me.. __-(Battery)+____(button)___(ATmega8)That's not even a closed circuit?
Quote from: Robotboy86 on April 07, 2009, 03:15:14 PMButtons typically have 2 leads coming off of them. One of these you will connect to an open Atmega digital pin. The other will be connected to a 5v source.The button sits between the Atmega and the 5v source, when you push the button, it will connect the Atmega and the 5v source, thus providing the Atmega with a "1"(Digital for ON). When the button is pushed it is connected to 5V and registers to reading that port as a "1", or high, or 5V (whatever nomenclature you are comfortable with).The trouble is that when the button is NOT pushed, then nothing is connected to the port. When nothing is connected to the port, the port input is "floating". A floating digital input can be subject to being at an unknown voltage level, which could also register as a 1/high/5V when the port is read.The solution is to use a high value resistor to pull the input to a known state. In this case, a resistor connected to the input and to ground. Again in this case, a value of 10,000 to 100,000 ohms would be appropriate. The resistor pulls the floating input to 0/low/0V and the switch pulls the input to 1/high/5V.It is equally valid to pull the input up to 5V (hence the term "pull up") and have the switch connect to ground.
GalacticNerd:See my previous post.But also in your circuit the 5V supply has a ground connection that would share the connection to ground with the ATmega8 ground pins.
I have a question a tad bit off of your topic, what model number Nokia LCD are you using and where can I get one? I've been trying to get a Nokia LCD for awhile without success.
All of the pin connections to port D are available. Duplicate the resistor/switch schematic I posted above for each of 7 inputs.
...
recognize a switch?
im not too sure on the code side of things but heres the arduino code which uses an atmega168 which is same pinout.int inPin = 2; // choose the input pin (for a pushbutton)void setup() { pinMode(inPin, INPUT); // declare pushbutton as input}im not too sure if thats right but it should give you an idea of what it will look like. with the inpin part of things i think you can change the 'in' part of things but im not sure, this is with the arduino after all which may have different code.
yes indeed i did, you can change it but i would leave it as inpin for simplicity, are you using a breadboard?
i think they will as long as its 'blahpin' i think it needs pin at the end. but dont be sure, this is for arduino, not sure if they are the same. but they should be extremly similar.
Quote from: SmAsH on April 08, 2009, 04:05:23 AMyes indeed i did, you can change it but i would leave it as inpin for simplicity, are you using a breadboard?No, at the moment, I'm just drawing everything out, and when I'm 100% sure the hardware part is okay, I'll hook it up on a prototyping board.Thanks for helping. Btw, it can't be named that way, because I'll have 7 buttons. So any name will do?
Quote from: GalacticNerd on April 08, 2009, 04:15:43 AMQuote from: SmAsH on April 08, 2009, 04:05:23 AMyes indeed i did, you can change it but i would leave it as inpin for simplicity, are you using a breadboard?No, at the moment, I'm just drawing everything out, and when I'm 100% sure the hardware part is okay, I'll hook it up on a prototyping board.Thanks for helping. Btw, it can't be named that way, because I'll have 7 buttons. So any name will do?"inPin" is just a variable name and can be named almost anything. Best to stick to alphanumerics, though.All that that statement did was assign the variable "inPin" the value of 2. When "inPin" is used later in the code, it has the value of 2.Using a define is a better way to do this as it doesn't waste RAM. But I don't think it would do you any good to describe that until you have _some_ sense of programming in C.To get some information about programming that you can find yourself (rather than being taught in this thread), please look through the tutorials on this site and then look here:http://www.learn-c.comhttp://www.learn-c.com/experiment1.htm