Hello, i am a newbie. I want to make LED lights up sequentially every time i push a button.
but my program cause all 3 led to light sequentially. Here is my program.
int timer = 1000;
int ledPins[] = {
5, 6, 7 }; // an array of pin numbers to which LEDs are attached
int pinCount = 3; // the number of pins (i.e. the length of the array)
int button = 8;
int thisPin = 0;
void setup() {
No, what i want is every time i push a button , a led will light up. When i depressed, it will be off.
So i need to push a button 3 times for 3 different led to light up. Right now , when i pressed the button , all 3 will light up.
You need to look at the state change detection example to determine when a switch BECOMES pressed, rather than blocking until the switch is pressed. Then, you need to count the number of times the switch is pressed. Light up the appropriate LEDs based on the number of times the switch has been pressed, NOT using a for loop.