Please let me know that about up-counting using Arduino UNO with button connect to pin 2 and 7-segment display.
When I press button it counts only one time.
I want to count-up and still counter going up until I release the button.
But I tried but not working
Can anyone one interested to tell me?
reading2 = digitalRead(CTAmp_button);
if (reading2 != lastButtonState2)
{
lastDebounceTime2 = millis();
}
if ((millis() - lastDebounceTime2) > debounceDelay2)
{
if (reading2 != buttonState2)
{
buttonState2 = reading2;
if (buttonState2 == HIGH)
{
Counter ++;
}
}
}
lastButtonState2 = reading2;
Num = Counter;
a = Num / 1000; //If Num=1234 Then a=1;
temp1 = Num % 1000; //If Num=1234 Then temp1=234;
b = temp1 / 100; //If temp1=234 Then b=2;
temp2 = temp1 % 100; //If temp1=234 Then temp2=34;
c = temp2 / 10; //If temp2=34 Then c=3;
d = temp2 % 10; //If temp2=34 Then d=4;
display (a);
display (b);
display (c);
display (d);