Hackster is hosting Hackster Holidays, Ep. 7: Livestream & Giveaway Drawing. Watch previous episodes or stream live on Friday!Stream Hackster Holidays, Ep. 7 on Friday!
jehankandt
Published © Apache-2.0

Arduino 6 LED Patterns

Arduino 6 LED Patterns

BeginnerFull instructions provided5,742
Arduino 6 LED Patterns

Things used in this project

Hardware components

Arduino UNO
Arduino UNO
×1
5 mm LED: Red
5 mm LED: Red
×10
Resistor 220 ohm
Resistor 220 ohm
×10
Jumper wires (generic)
Jumper wires (generic)
×1

Software apps and online services

Arduino IDE
Arduino IDE

Story

Read more

Schematics

Arduino 6 LED Patterns

Arduino 6 LED Patterns

Code

Arduino 6 LED Patterns

C/C++
Arduino LED Patterns
int t = 100;
int x;  
int counter = 10;

void setup() {
 for(int i = 4; i <= 13; i++){
  pinMode(i,OUTPUT);
 }
}

void loop() {

  for(int i = 0; i <= counter; i++){
    pat1();
  }
  for(int i = 0; i <= counter; i++){
    pat2();
  }
  for(int i = 0; i <= counter; i++){
    pat3();
  }
  for(int i = 0; i <= counter; i++){
    pat4();
  }
  for(int i = 0; i <= counter; i++){
    pat5();
  }
  for(int i = 0; i <= counter; i++){
    pat6();
  }
  for(int i = 0; i <= counter; i++){
    pat7();
  }
  
}

void pat1(){ 
  for(int i = 4; i <= 13; i++){
    digitalWrite(i,HIGH);
    delay(t);
    digitalWrite(i,LOW);
  }
  for(int i = 12; i >= 4; i--){
    digitalWrite(i,HIGH);
    delay(t);
    digitalWrite(i,LOW);
  }
}
void pat2(){
  for(int i = 4; i<=13; i=i+2){
    digitalWrite(i,HIGH);
    delay(t);
    digitalWrite(i,LOW); 
  }
  for(int i = 12; i>=4; i=i-2){
    digitalWrite(i,HIGH);
    delay(t);
    digitalWrite(i,LOW);
  }
}
void pat3(){
  for(int i = 4; i <= 13; i++){
    digitalWrite(i,HIGH);
    delay(t);
  }
  for(int i = 13; i >= 4; i--){
    digitalWrite(i,LOW);
    delay(t);
  }
}
void pat4(){
  for(int i = 4; i <= 8; i++){
    digitalWrite(i,HIGH);
  }
  delay(500);
  for(int i = 4; i <= 8; i++){
    digitalWrite(i,LOW);
  }
  

  
  for(int i = 9; i <= 13; i++){
    digitalWrite(i,HIGH);
  }
  delay(500);
  
  for(int i = 9; i <= 13; i++){
    digitalWrite(i,LOW);
  }

  
}

void pat5(){
  digitalWrite(4,HIGH);
  digitalWrite(5,HIGH);
  digitalWrite(6,HIGH);
  digitalWrite(11,HIGH);
  digitalWrite(12,HIGH);
  digitalWrite(13,HIGH);

  delay(500);

  digitalWrite(4,LOW);
  digitalWrite(5,LOW);
  digitalWrite(6,LOW);
  digitalWrite(11,LOW);
  digitalWrite(12,LOW);
  digitalWrite(13,LOW);

  digitalWrite(7,HIGH);
  digitalWrite(8,HIGH);
  digitalWrite(9,HIGH);
  digitalWrite(10,HIGH);

  delay(500);

  digitalWrite(7,LOW);
  digitalWrite(8,LOW);
  digitalWrite(9,LOW);
  digitalWrite(10,LOW);
}
void pat6(){
  for(int i = 4; i<=13; i=i+2){
    digitalWrite(i,HIGH);
  }
  
  delay(500);
  
  for(int i = 4; i<=13; i=i+2){
    digitalWrite(i,LOW);
  }

  
  
  for(int i = 5; i<=13; i=i+2){
    digitalWrite(i,HIGH);
  }

  delay(500);

  for(int i = 5; i<=13; i=i+2){
    digitalWrite(i,LOW);
  }
}
void pat7(){
  int d = 1;
  for(int a = 9; a<=13; a++){
    digitalWrite(a,HIGH);
    digitalWrite((a - d),HIGH);
    delay(t);

    digitalWrite(a,LOW);
    digitalWrite((a - d),LOW);

    
    d = d + 2;
  }
}

Credits

jehankandt
21 projects • 8 followers

Comments