Pages

Wednesday, May 30, 2018

Arduino LED lesson(Knight Rider)

Ignite few LEDs by using "for loops"

Required components:-
   1). Arduino uno(you can use any type)
2). 8×LEDs
3). 8× 220 ohms resistors
4). Few jumper wires
5). Breadboard



Step 01:- 
Connect your LEDs and resistors to the breadboard as in the picture given above.

Step 02:-
Connect the eight resistors which connected to the LEDs to GND pin in arduino board.

Step 03:-
Connect the (+) pins of LEDs to 6,7,8,9,10,11,12,13 pins in arduino board.

Step 04:-
Now uploas the code given below.


Code:

void setup(){

for(int i=6; i<=13; i++){
pinMode(i, OUTPUT);
}
}

void loop(){

for(int j=6; j<=13; j++){
digitalWrite(j, HIGH);
delay(100);
digitalWrite(j, LOW);
}

for(int j=12; j>6; j--){
digitalWrite(j, HIGH);
delay(100);
digitalWrite(j, LOW);
}
}











No comments:

Post a Comment