I have a circuit with Arduino, LED and button and I need that sketch would be able to make these actions:
- Pressing the button turns the LED on for 2 seconds after which it turns off again.
- If the button is pressed while the LED is on, the 2-second on time shall be reset so
that it will be on for another 2 seconds (i.e., it gets retriggered).
- After the LED has been on for 2 seconds and then off, it shall not be possible to turn
the LED on again for 3 seconds.
- After each time the LED has been on, print a serial message with how many times the
LED has been turned on.
I’m am completely bad in mixing several codes. In this code it is not possible to reset LED more than once, then it is off for 3sec. If I press the button more than twice, it delays on for 4 sec. Then it is off for 3sec. And I need to make it possible to reset every time LED is on.
Could you give me any advice how should I change my code? Probably I added too many stuff.
astuntas.ino (1.69 KB)