Experimental Purpose:
Use arduino to realize a small test of running lights, so that each small light goes on and off in sequence (the previous small light goes off while the next small light goes on) and lasts for 200ms.

Step 1: Components used, one arduino uno board, 8 led lights, 8 220Ω resistors, a number of Dupont wires, one breadboard.

Plug the bottom wire (GND) into the negative terminal of the breadboard (this step can be done anytime). Insert the led and resistor into the breadboard as shown in the picture

Wiring according to the diagram, pay attention to the correspondence between the port and the small light

Connect both negative terminals of the small lamps to the negative terminal of the breadboard.

The code used for the experiment is as follows:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
/*实现流水灯
让每个小灯依次亮灭,每个小灯亮200ms*/
void setup()
{
for(int i = 6; i <= 13; i++)
{
pinMode(i, OUTPUT);//让6到13号接口输出电频
}
}

void loop() {
digitalWrite(6,LOW);//6灯灭
digitalWrite(7,HIGH);//7灯亮
delay(200);//延迟200ms

digitalWrite(7,LOW);//7灯灭
digitalWrite(8,HIGH);//8灯灭
delay(200);//延迟200ms

digitalWrite(8,LOW);//8灯灭
digitalWrite(9,HIGH);//9灯灭
delay(200);//延迟200ms

digitalWrite(9,LOW);//9灯灭
digitalWrite(10,HIGH);//10灯灭
delay(200);//延迟200ms

digitalWrite(10,LOW);//10灯灭
digitalWrite(11,HIGH);//11灯灭
delay(200);//延迟200ms

digitalWrite(11,LOW);//11灯灭
digitalWrite(12,HIGH);//12灯灭
delay(200);//延迟200ms

digitalWrite(12,LOW);//12灯灭
digitalWrite(13,HIGH);//13灯灭
delay(200);//延迟200ms

digitalWrite(13,LOW);//13灯灭
digitalWrite(6,HIGH);//6灯灭
delay(200);//延迟200ms

}

The program runs on Tinkercad with the following results.

Enter the code and check the port.

Compile and upload to arduino boards

The overall hardware connection of the experiment is shown in Fig.

The results of the experimental runs are as follows.



Reference

https://blog.csdn.net/foolbirdM/article/details/112733676
https://www.ncnynl.com/archives/201607/355.html