How are all of my young friends, hopefully they are always in good health and always given safety by the almighty, for friends who are not healthy, I hope you get well soon so they can do their daily work as usual, amiin.
Well, let's continue the Arduino tutorial, this time our tutorial is about LEDs, namely LEDs running back and forth using Arduino. For this time, the components that we ordered were only 2, namely LED 10 and Resistor 100ohm only. For more details, let's go straight.
- Tools and materials
- LED12 Pieces
- Resistor 100ohm or close to 12 pieces
- Experiment board
- Arduino
- Jumper
- Circuit Path
- Coding program
int led1 = 3;
int led2 = 4;
int led3 = 5;
int led4 = 6;
int led5 = 7;
int led6 = 8;
int led7 = 9;
int led8 = 10;
int led9 = 11;
int led10 = 12;
void setup() {
// put your setup code here, to run once:
pinMode(led1,OUTPUT);
pinMode(led2,OUTPUT);
pinMode(led3,OUTPUT);
pinMode(led4,OUTPUT);
pinMode(led5,OUTPUT);
pinMode(led6,OUTPUT);
pinMode(led7,OUTPUT);
pinMode(led8,OUTPUT);
pinMode(led9,OUTPUT);
pinMode(led10,OUTPUT);
}
void loop() {
// put your main code here, to run repeatedly:
digitalWrite(led1,1);
delay(10);
digitalWrite(led2,1);
delay(10);
digitalWrite(led3,1);
delay(10);
digitalWrite(led4,1);
delay(10);
digitalWrite(led5,1);
delay(10);
digitalWrite(led6,1);
delay(10);
digitalWrite(led7,1);
delay(10);
digitalWrite(led8,1);
delay(10);
digitalWrite(led9,1);
delay(10);
digitalWrite(led10,1);
delay(10);
digitalWrite(led1,0);
delay(100);
digitalWrite(led2,0);
delay(10);
digitalWrite(led3,0);
delay(10);
digitalWrite(led4,0);
delay(10);
digitalWrite(led5,0);
delay(10);
digitalWrite(led6,0);
delay(10);
digitalWrite(led7,0);
delay(10);
digitalWrite(led8,0);
delay(10);
digitalWrite(led9,0);
delay(10);
digitalWrite(led10,0);
delay(10);
digitalWrite(led10,1);
delay(10);
digitalWrite(led9,1);
delay(10);
digitalWrite(led8,1);
delay(10);
digitalWrite(led7,1);
delay(10);
digitalWrite(led6,1);
delay(10);
digitalWrite(led5,1);
delay(10);
digitalWrite(led4,1);
delay(10);
digitalWrite(led3,1);
delay(10);
digitalWrite(led2,1);
delay(10);
digitalWrite(led1,1);
delay(10);
digitalWrite(led10,0);
delay(10);
digitalWrite(led9,0);
delay(10);
digitalWrite(led8,0);
delay(10);
digitalWrite(led7,0);
delay(10);
digitalWrite(led6,0);
delay(10);
digitalWrite(led5,0);
delay(10);
digitalWrite(led4,0);
delay(10);
digitalWrite(led3,0);
delay(10);
digitalWrite(led2,0);
delay(10);
digitalWrite(led1,0);
}
Copy the code above to the Arduino IDE, then upload it.
Note: for those of you who want more LEDs but lack pins on the Arduino, you can buy an Arduino with more pins.
Now that's how to make LEDs run back and forth using Arduino, hopefully it's useful, I'll end with technology greetings