Please Let Me Know How Much You Like This (1 is very Bad - 10 is Excellent)

Controlling five LEDs with a button in a sequence with Arduino.

Using modulus operator we can turn on and off LEDs in sequence.

By using arrays we can shorten the code as seen below

29 Apr 2016

i'd like to do this with 1 button and only 3 led's what would the code look like for that ?

01 May 2016

In the second program change
int numberOfLED = 5;
int numberOfLED = 3;
and use first 3 LED.

20 Mar 2017

For the array I get the following errors, what's going on?

Button_Press-_Next_LED:1: error: expected unqualified-id before numeric constant
1: //
Button_Press-_Next_LED:9: error: expected unqualified-i

29 Mar 2017

Cut and Paste operation takes the line numbers also. Please delete all the line numbers from Arduino program after pasting it.

jim de groot
08 May 2017

thanks for the great code tought me a lot I am currently stuck at getting my head around the following line of code:
if (buttonPressCount % numberOfLED == i)
if I translate this it would be:
if I press the button once (1 % 5 == 1) so far so good
2, 3 and 4 are also well understood
but if you press the button 5 times it would be: 5 % 5 == 0 so that would mean that there is no LED to switch on because i (5) in this case does not equal 0. Could you explain this??

26 Mar 2018

Thank you for this project.
The only thing is when you keep the button pressed, the light start to circle around. it would be nice to move from one light to the next one, only when press the button and not when you hold it pressed.

26 Oct 2018

I'll like to make a 4 way sequencer starting with power on, controlling the time separatly for each one of the outputs and stop when the power is off, ristarting automaticaly with the power on again. Possibility to set timers with wifi or android.

Jake Jacobson
07 Nov 2018

Is there any way to sequence 21 lights. I have an antique game scorer that has mechanical sequence switches that are shot and no longer available so I thought maybe modify
Thanks, Jake

08 Nov 2018

Hi Jake.
Yes, there is. Use 3 daisy chained shift register to accomplish it. Please look at the following link

Thomas B
24 Apr 2019

hey im having an issue im trying to get my program to where when i press the button the first one comes on then press the button and have both the first and second led to stay on.

07 Aug 2019

thank for good data

06 Jan 2020

First of all, thanks for the very useful tutorial you made.
I have the following question: How to integrate a while loop with an if statement (or a switch case)?


Add a comment or brief description of this mechanism in your language.

LEGIT Comments will be displayed in 24 hours.

55 + 5 =

Leave this empty: