Introduction: Led + Arduino "running Light" (very Simple, Good for Beginners)
hello
so this is my first arduino project. it is very very simple and it is good for beginners
basicly its just leds hooked up in a row to make a running light
so this is my first arduino project. it is very very simple and it is good for beginners
basicly its just leds hooked up in a row to make a running light
Attachments
Step 1: Materials
-8 x Led (I used 3V Leds because i didnt have 5v ones)
-Arduino
-Breadboard
-Jumper Wires
Optional:
-Prototyping Shield
-Arduino
-Breadboard
-Jumper Wires
Optional:
-Prototyping Shield
Step 2: Buiding It
Wire it up following the schematic below.
sorry for the mistake its pin 5 not 7^^
sorry for the mistake its pin 5 not 7^^
Step 3: The Code
Heres the very basic code:
boolean t = true;
int i = 12;
void setup()
{
pinMode(12,OUTPUT);
pinMode(11,OUTPUT);
pinMode(10,OUTPUT);
pinMode(9,OUTPUT);
pinMode(8,OUTPUT);
pinMode(7,OUTPUT);
pinMode(6,OUTPUT);
pinMode(5,OUTPUT);
pinMode(4,OUTPUT);
}
void loop()
{
digitalWrite(i,HIGH);
delay(50);
digitalWrite(i,LOW);
if(t == true)
{
i = i - 1;
}
else
{
i = i + 1;
}
if(i < 5)
{
i = 6;
t = false;
}
if(i > 12)
{
i = 11;
t = true;
}
}
boolean t = true;
int i = 12;
void setup()
{
pinMode(12,OUTPUT);
pinMode(11,OUTPUT);
pinMode(10,OUTPUT);
pinMode(9,OUTPUT);
pinMode(8,OUTPUT);
pinMode(7,OUTPUT);
pinMode(6,OUTPUT);
pinMode(5,OUTPUT);
pinMode(4,OUTPUT);
}
void loop()
{
digitalWrite(i,HIGH);
delay(50);
digitalWrite(i,LOW);
if(t == true)
{
i = i - 1;
}
else
{
i = i + 1;
}
if(i < 5)
{
i = 6;
t = false;
}
if(i > 12)
{
i = 11;
t = true;
}
}