Arduino buttons moving in lock step -


i have arduino project (it's mintduino, it's same microcontroller) has 3 buttons, setup tutorial (http://arduino.cc/en/tutorial/buttonstatechange) common + , - between them. buttons individually connected a0, a1, , a2. here code use read them:

void setup() {   pinmode(a0, input);   pinmode(a1, input);   pinmode(a2, input);    serial.begin(9600); }  void loop() {   serial.print("b1: ");   serial.print(digitalread(a0));   serial.print("  b2: ");   serial.print(digitalread(a1));   serial.print("  b3: ");   serial.print(digitalread(a2));   serial.println(""); } 

when button unpressed, get:

b1: 1 b2: 1 b3: 1

and when press any button, get:

b1: 0 b2: 0 b3: 0

so can tell button pressed, , can not tell button was pressed. how can tell 1 button press another?

i think know why it's happening, can't think of solution doesn't involve using 3 different batteries can individual circuits.

most got wiring wrong. or code not match wiring.

first should not use a0, a1, a2 digital pins. notice a0, a1, a2 double digital pins different numbers.

so reading different pins pins expect read.

the next thing might missing pull / pull down resistors. unfortunately tutorial sucks. not tell internal pull resistors allow ditch external resistor described in tutorial.

if way suspect, pins floating , picking random noise. can have number of symptoms including symptoms describe. suggest extend code read digital pins 0 19 , see how reacts button pushes. know proper pin numbers.

in case no pin reacts desired got wiring wrong.


Comments

Popular posts from this blog

SPSS keyboard combination alters encoding -

Add new record to the table by click on the button in Microsoft Access -

CSS3 Transition to highlight new elements created in JQuery -