Hi,
So we have a project to demo, we are getting four input pins and printing them on the computer as 1's or 0's. Say, if you press button 1, code 0001 goes to screen. But sometimes it prints 00010001.
At first, it may look like debouncing time is not enough, but that could be fixed by increasing it. But the real problem is that sometimes, it continuously prints data onto screen even if no button is pressed.
We also tried to remove the power supply from the buttons-circuit board, but it continues to print random codes onto the screen even if the buttons aren't powered.
We have buttons connected to vdd and gnd, we also connect diodes to each button prevent code mixup.
What may be the problem, what should we 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 at bottom of com7
Serial.println(0);
Serial.println(0);
Serial.println(1);
delay(200);
}
On the buttons, we are using pull down resistors and vdd. so when you push the button, the vdd is taken to digital input of arduino. Diodes are to give reverse bias because we only have four pins for 13 buttons, and we don't want one button turning on all the buttons connected to its pins. But I don't have a picture of it.