2.4 Experimental platform
According to Figure 2-2, we start to set up the experimental platform, as shown Figure 2-2. Oh, my god, there are so much LEDs, dupont lines, and resistors, that we are confused by the complex connection. But can we rightly connect the electrical elements? In fact, it is not difficult if we can find a technique. Then, it will be very simple to set up our such experiment.
As for one LED, the long les is located left side for positive, and the other is located right side for negative. if all of these LEDs are connected by this method, it is not a problem.
One end of dupont line is connected to negative polarity (by the equal voltage for each column in the brandboard). Another end is connected to GND. All of these ends are connected the same line in the narrow band (the equal voltage for each row in the narrow band).
The current-limited resistors are connected to the polarities of LEDs. Similarly, they are located randomly in the same column. But for the good-looking, they had better be connected unifiedly the different columns at the same line in the brandband. It will look like neat, as shown in Figure 2-2.
One end is connected to resistor at the same column, and the other is connected to the pins on the Arduino board, as shown in Figure 2-2.
OK, when you have a few techniques to connect these electronic elements on the Arduino board, you may finish this connection of this experiment successfully at a time. The circuit is not complex, but it needs your carefulness.
Wow, when we insert USB line into computer and Arduino board, the LED is blinking repeatedly at pin 8 on the Arduino board. But other LEDs are honest, and not blinking. Why? Yes, maybe, you have got it. Do you remember the previous experiment? We let LED blink located at pin 8 on the Arduino board. When the code has been burnt into the Arduino board, it can be saved in the board forever. It does not disappear with the power off of Arduino board. If we repower on the Arduino board, the LED will blink at pin 8. But, if we burn a new program into the Arduino board, the board will execute the new code.
Figure 2-3 Start to write the letter V
Figure 2-4 The letter V
2.5 Solution for code
On the basis of the last experiment on the Arduino IDE, we can give out the code in this experiment, which is exhibited in Program 2.
01 //Program 2: Arduino controls many LEDs
02 //define 9 pins for LEDs
03 int led4 = 4;
04 int led5 = 5;
05 int led6 = 6;
06 int led7 = 7;
07 int led8 = 8;
08 int led9 = 9;
09 int led10 = 10;
10 int led11 = 11;
11 int led12 = 12;
13 //initialize the 9 pins as OUTPUT
14 void setup()
16 for(int i=4;i<=12;i++)//define 4-12 as OUTPUT
17 pinMode(i,OUTPUT);//set i as OUTPUT
20 void loop()
22 mode();//display of 9 LEDs
25 //subfunction for mode()
26 void mode()
28 unsigned char j;
29 //let 4-12 LEDs blink one by one
35 //let 4-12 LEDs go out
41 //let 4-12 LEDs bright
2.6 Key points
1) Be familiar with the polarity of LED and the features of breadboard.
2) After finishing a experiment, we should summarize some experiences from the process of experiment.
3) Arduino can realize your idea. Do it yourself.