The Arduino is a great platform for playing with electronics. It’s open source hardware and it has a great community behind it. Most of us tried Blinking LED using Arduino as a Beginner. Let’s do something cool using LED's with Arduino. In this project, we will make LED's blink in different patterns. The program has totally 11 different patterns. You can include more patterns if you like.
Components Required :
To Purchase the Components Click on the Links given i.e FlyRobo or Robu.in
- 1 x Breadboard ( FlyRobo : http://bit.ly/2rwkVT3 ; Robu.in : http://bit.ly/2PrO9dU )
- 9 x LED's ( FlyRobo : http://bit.ly/2t1dbci )
- 9 x Resistors (220 Ω) ( FlyRobo : http://bit.ly/38oE2is ; Robu.in : http://bit.ly/38l8OsH )
- 1 x Arduino Uno Board ( FlyRobo : http://bit.ly/2DXF733 ; Robu.in : http://bit.ly/2RBA9B8 )
- Jumper Wires ( FlyRobo : http://bit.ly/2qzBQ6L ; Robu.in : http://bit.ly/2LzGwRq )
- Arduino USB Cable
Circuit Diagram :
Source Code :
Note : Remove Rx/Tx pins of Arduino while uploading the Code.
/*
Multiple LED Patterns Using Arduino
HarshTronics
For More :
https://www.harshtronic.blogspot.com
https://www.instagram.com/harshtronics
*/
void setup()
{
for (int i = 5; i <= 13; i++) // Set Pins 5 to 13 as Output
{
pinMode(i, OUTPUT);
}
}
void loop()
{
for(int i=0;i<5;i++) { pattern1(); } //pattern 1
for(int i=0;i<5;i++) { pattern2(); } //pattern 2
for(int i=0;i<5;i++) { pattern3(); } //pattern 3
for(int i=0;i<5;i++) { pattern4(); } //pattern 4
for(int i=0;i<5;i++) { pattern5(); } //pattern 5
for(int i=0;i<5;i++) { pattern6(); } //pattern 6
for(int i=0;i<5;i++) { pattern7(); } //pattern 7
for(int i=0;i<5;i++) { pattern8(); } //pattern 8
for(int i=0;i<5;i++) { pattern9(); } //pattern 9
for(int i=0;i<5;i++) { pattern10(); } //pattern 10
for(int i=0;i<25;i++) { pattern11(); } //pattern 11
clear();
delay(5000);
}
void pattern1()
{
for(int i=5;i<14;i++)
{
digitalWrite(i,HIGH);
delay(100);
digitalWrite(i,LOW);
}
}
void pattern2()
{
for(int j=5; j<14; j++)
{
digitalWrite(j, HIGH);
delay(30);
digitalWrite(j, LOW);
delay(30);
}
for(int k = 15; k>5; k--)
{
digitalWrite(k, HIGH);
delay(30);
digitalWrite(k, LOW);
delay(30);
}
}
void pattern3()
{
for(int i=5;i<14;i++)
{
digitalWrite(i,HIGH);
delay(100);
}
for(int i=5;i<14;i++)
{
digitalWrite(i,LOW);
delay(100);
}
}
void pattern4()
{
for(int i = 15; i >= 5; i--)
{
digitalWrite(i, HIGH);
delay(20);
digitalWrite(i+1, LOW);
delay(20);
}
for(int i = 15; i >= 5; i--)
{
digitalWrite(i+1, HIGH);
delay(20);
digitalWrite(i+2, LOW);
delay(20);
}
for(int i = 15; i >= 5; i--)
{
digitalWrite(i+2, HIGH);
delay(20);
digitalWrite(i+3, LOW);
delay(20);
}
for(int i = 15; i >= 5; i--)
{
digitalWrite(i+3, HIGH);
delay(20);
digitalWrite(i+4, LOW);
delay(20);
}
for(int i = 15; i >= 5; i--)
{
digitalWrite(i+4, HIGH);
delay(20);
digitalWrite(i+5, LOW);
delay(20);
}
for(int i = 15; i >= 5; i--)
{
digitalWrite(i+5, HIGH);
delay(20);
digitalWrite(i+6, LOW);
delay(20);
}
for(int i = 15; i >= 5; i--)
{
digitalWrite(i+6, HIGH);
delay(20);
digitalWrite(i+7, LOW);
delay(20);
}
for(int i = 15; i >= 5; i--)
{
digitalWrite(i+7, HIGH);
delay(20);
digitalWrite(i+8, LOW);
delay(20);
}
for(int i = 15; i >= 5; i--)
{
digitalWrite(i+8, HIGH);
delay(20);
digitalWrite(i+9, LOW);
delay(20);
}
for(int i = 15; i >= 5; i--)
{
digitalWrite(i+9, HIGH);
delay(20);
digitalWrite(i+10, LOW);
delay(20);
}
for(int i = 15; i >= 5; i--)
{
digitalWrite(i+10, HIGH);
delay(20);
digitalWrite(i+11, LOW);
delay(20);
}
for(int i = 15; i >= 5; i--)
{
digitalWrite(i+13, HIGH);
delay(20);
digitalWrite(i, LOW);
}
}
void pattern5()
{
for(int j=5; j<14; j++)
{
digitalWrite(j, LOW);
delay(30);
digitalWrite(j, HIGH);
delay(30);
digitalWrite(j-2, LOW);
delay(30);
digitalWrite(j, HIGH);
}
for(int k = 15; k>5; k--)
{
digitalWrite(k, LOW);
delay(30);
digitalWrite(k, HIGH);
delay(30);
digitalWrite(k+2, LOW);
delay(30);
digitalWrite(k, HIGH);
}
}
void clear()
{
for(int i=5;i<14;i++)
{
digitalWrite(i,LOW);
}
}
void pattern6()
{
int count = 13;
for (int i = 5; i < 13; i++)
{
clear();
digitalWrite(i, HIGH);
digitalWrite(count, HIGH);
count--;
if (count != 9)
{
delay(100);
}
}
for (int i = 13; i > 5; i--)
{
clear();
digitalWrite(i, HIGH); // chaser 1
digitalWrite(count, HIGH); // chaser 2
count++;
if (count != 10)
{
delay(100);
}
}
}
void pattern7()
{
for(int i=5; i<14; i++)
{
digitalWrite(i, HIGH);
delay(50);
}
for(int i=5; i<14; i++)
{
digitalWrite(i, LOW);
delay(50);
}
for(int i = 14; i>=5; i--)
{
digitalWrite(i, HIGH);
delay(50);
}
for(int i = 14; i>=5; i--)
{
digitalWrite(i, LOW);
delay(50);
}
}
void pattern8()
{
for(int j = 5; j <= 13; j++)
{
digitalWrite(j, HIGH);
delay(100);
j=j+1;
}
for(int j = 5; j <= 13; j++)
{
digitalWrite(j, LOW);
delay(100);
}
for(int k = 14; k > 5; k--)
{
digitalWrite(k, HIGH);
delay(100);
k=k-1;
}
for(int k = 14; k > 5; k--)
{
digitalWrite(k, LOW);
delay(100);
}
}
void pattern9()
{
{
digitalWrite(5,HIGH);
digitalWrite(7,HIGH);
digitalWrite(9,HIGH);
digitalWrite(11,HIGH);
digitalWrite(13,HIGH);
digitalWrite(6,LOW);
digitalWrite(8,LOW);
digitalWrite(10,LOW);
digitalWrite(12,LOW);
}
delay(150);
{
digitalWrite(5,LOW);
digitalWrite(7,LOW);
digitalWrite(9,LOW);
digitalWrite(11,LOW);
digitalWrite(13,LOW);
digitalWrite(6,HIGH);
digitalWrite(8,HIGH);
digitalWrite(10,HIGH);
digitalWrite(12,HIGH);
}
delay(150);
}
void pattern10()
{
{
digitalWrite(5,HIGH);
digitalWrite(6,HIGH);
digitalWrite(7,HIGH);
digitalWrite(8,HIGH);
digitalWrite(9,HIGH);
digitalWrite(10,LOW);
digitalWrite(11,LOW);
digitalWrite(12,LOW);
digitalWrite(13,LOW);
}
delay(150);
{
digitalWrite(9,HIGH);
digitalWrite(10,HIGH);
digitalWrite(11,HIGH);
digitalWrite(12,HIGH);
digitalWrite(13,HIGH);
digitalWrite(5,LOW);
digitalWrite(6,LOW);
digitalWrite(7,LOW);
digitalWrite(8,LOW);
}
delay(150);
}
void pattern11()
{
int randomled = random(5, 14);
digitalWrite(randomled, HIGH);
delay(50);
digitalWrite(randomled, LOW);
delay(50);
}
/*
HarshTronics
For More :
https://www.harshtronic.blogspot.com
https://www.instagram.com/harshtronics
*/
No comments:
Post a Comment