Creative solution
Published

For Loop

Arduino tutorial

BeginnerFull instructions provided349
For Loop

Things used in this project

Hardware components

Arduino UNO & Genuino UNO
Arduino UNO & Genuino UNO
×1
5 mm LED: Red
5 mm LED: Red
×1

Software apps and online services

Arduino IDE
Arduino IDE

Story

Read more

Code

For Loop

Arduino
void setup() {
  // put your setup code here, to run once:
pinMode(5,OUTPUT);
pinMode(6,OUTPUT);
pinMode(7,OUTPUT);
pinMode(8,OUTPUT);
pinMode(9,OUTPUT);
}

void loop() {
  // put your main code here, to run repeatedly:
int t=200;
for(int i=5; i< 10; i=i+1){ // i= first on LED pin //
                               // i=i+1 or i++(count) 
  digitalWrite(i,HIGH);
  delay(t);
  digitalWrite(i,LOW);
}
for(int p=8; p>5; p=p-1){
  digitalWrite(p,HIGH);
  delay(t);
  digitalWrite(p,LOW); 
}
}

Credits

Creative solution

Creative solution

7 projects • 3 followers

Comments