Arduino Lesson 4
Advertising light
We often see some billboards, composed of all sorts of color of the led
lamp constantly change. This experiment will show you the basic effects.
1)Parts require
Leds:6
220Ω Resistor:6
Jumper Wires:1 Bundle
2)Connection
Put 6 leds on pins in order as below
Program for reference
int BASE = 2 ; //First LED I/O contact
int NUM = 6; //LED Numbers
void setup()
{
for (int i = BASE; i < BASE + NUM; i ++)
{
pinMode(i, OUTPUT); // Setup digital I/O as output
}
}
void loop()
{
for (int i = BASE; i < BASE + NUM; i ++)
{
digitalWrite(i, LOW); // Setup digital I/O output as “low” which means turn on
the light gradually
delay(200); //Delay
}
for (int i = BASE; i < BASE + NUM; i ++)
{
digitalWrite(i, HIGH); //Setup digital I/O output as “low” which means turn on
the light gradually
delay(200); //Delay
}
}