In this lesson we will build an LED Sequencer
This circuit connects 4 digital output pins to LEDs. When the digital output connected to an LED is set high, the LED lights up.
Above is a picture of the circuit on a breadboard. At the moment this photo was taken, output D3 on the microcontroller was set high, and the second LED from the left is lit up.
Here is a program you can use to test the LED sequencer.
void setup()
{
pinMode(2, OUTPUT);
pinMode(3, OUTPUT);
pinMode(4, OUTPUT);
pinMode(5, OUTPUT);
}
int position;
void loop()
{
digitalWrite(position + 2, HIGH);
delay(100);
digitalWrite(position + 2, LOW);
delay(100);
position = position + 1;
if (position > 3)
{
position = 0;
}
}
Can you add another LED to the sequencer? What steps do you need to take?