Problem with button readins?
hi,
so have project demo, getting 4 input pins , printing them on computer 1's or 0's. say, if press button 1, code 0001 goes screen. prints 00010001.
at first, may debouncing time not enough, fixed increasing it. real problem sometimes, continuously prints data onto screen if no button pressed.
we tried remove power supply buttons-circuit board, continues print random codes onto screen if buttons aren't powered.
we have buttons connected vdd , gnd, connect diodes each button prevent code mixup.
what may problem, should do?
edit ..................... code example;
void loop()
{
current1 = digitalread(firstpin);
current2 = digitalread(secondpin);
current3 = digitalread(thirdpin);
current4 = digitalread(fourthpin);
delay(5);
current1 = digitalread(firstpin);
current2 = digitalread(secondpin);
current3 = digitalread(thirdpin);
current4 = digitalread(fourthpin);
if(current1 == low && current2 == low
&& current3 == low && current4 == high)
{
serial.println(0); // arduiono prints last number @ bottom of com7
serial.println(0);
serial.println(0);
serial.println(1);
delay(200);
}
on buttons, using pull down resistors , vdd. when push button, vdd taken digital input of arduino. diodes give reverse bias because have 4 pins 13 buttons, , don't want 1 button turning on buttons connected pins. don't have picture of it.
so have project demo, getting 4 input pins , printing them on computer 1's or 0's. say, if press button 1, code 0001 goes screen. prints 00010001.
at first, may debouncing time not enough, fixed increasing it. real problem sometimes, continuously prints data onto screen if no button pressed.
we tried remove power supply buttons-circuit board, continues print random codes onto screen if buttons aren't powered.
we have buttons connected vdd , gnd, connect diodes each button prevent code mixup.
what may problem, should do?
edit ..................... code example;
void loop()
{
current1 = digitalread(firstpin);
current2 = digitalread(secondpin);
current3 = digitalread(thirdpin);
current4 = digitalread(fourthpin);
delay(5);
current1 = digitalread(firstpin);
current2 = digitalread(secondpin);
current3 = digitalread(thirdpin);
current4 = digitalread(fourthpin);
if(current1 == low && current2 == low
&& current3 == low && current4 == high)
{
serial.println(0); // arduiono prints last number @ bottom of com7
serial.println(0);
serial.println(0);
serial.println(1);
delay(200);
}
on buttons, using pull down resistors , vdd. when push button, vdd taken digital input of arduino. diodes give reverse bias because have 4 pins 13 buttons, , don't want 1 button turning on buttons connected pins. don't have picture of it.
there's @ pins. whether down or not decides print if , when decide print something.
without seeing have far, it's impossible have made mistakes.
without seeing have far, it's impossible have made mistakes.
Arduino Forum > Using Arduino > Project Guidance > Problem with button readins?
arduino
Comments
Post a Comment