6.Arduino learning notebook--Digital Tube Experiment

6.Arduino learning notebook--Digital Tube Experiment

          Juvtmall ( a company supply PCB PrototypingPCBA service and sell kinds of components, modules and so on) ( Catduino has the same function of Arduino)

Digital tube introduction
A digital tube is a semiconductor luminescent device whose basic unit is a light-emitting diode.The number of digital tubes is divided into seven segments digital tubes and eight segments digital tubes, and the eight segments digital tubes is more than seven digital tubes with a single light-emitting diode unit (one decimal point display)
The connection mode of light-emitting diode unit is divided into the co-yang digital tube and the co-yin digital tube.The co-yang digital tube is a digital tube that all the anode of light-emitting diodes are connected together to form a common anode (COM).In the application, the PWR should be received by the PWR of the public pole. When the cathode of a field light-emitting diode is low level, the corresponding field will be lit. When the cathode of a field is high level, the corresponding field is not bright.The co-yin digital tube is opposite, all the cathode are connected together to form a common cathode, and the anode is separated separately.

Take a look at the digital tube used in this experiment.



It is found that it is 0.5 "single conjoined the co-yang digital tube by querying the model LG5011BSR, below shows the pin diagram.

 

Looking at the back of it, there are two origins and 5, 10 marks respectively in the four corners.They respectively represent 1, 6, 5, 10 pins.

Digital tube is the same as light-emitting diode, need to be added to the current-limiting resistance, since there is no information on how high the breakdown voltage of the digital tube is. So the voltage and power supply would rather small not big, to choose 220 Ω current-limiting resistor, and 3.3 V power supply.
The wiring diagram is shown below



 
































Download the following code to the control board and see the effect

ARDUINO code

1. / / set the digital IO pin that controls each field. Which pin is corresponding to which field, it is sourced from the official pin drawing of the digital tube.
2. int a = 7;
3. int b = 6;
4. int c = 5;
5. int d = 11;
6. int e = 10;
7. int f = 8;
8. int g = 9;
9. int dp = 4;
10. 
11. / / display digital 1
12. void digital_1 (void)
13. {
14. unsigned char j;
15.digitalWrite (c, LOW);/ / give the digital 5 pin the low level and light up the c field
16. for (j = 7;J < = 11;J + +) / / put out the rest field
18. digitalWrite (j, HIGH);
19.digitalWrite (dp, HIGH);/ / put out the decimal point
20. }
21. / / display digital 2
22. void digital_2 (void)
23. {
24. unsigned char j;
25. digitalWrite (b, LOW);
26. digitalWrite (a, LOW);
27.for (j = 9;J < = 11;J++)
28. digitalWrite (j, LOW);
29. digitalWrite (dp, HIGH);
30. digitalWrite (c, HIGH);
31. digitalWrite (f, HIGH);
32. }
33. / / display digital 3
34. void digital_3 (void)
35. {
36. unsigned char j;
37. digitalWrite (g, LOW);
38. digitalWrite (d, LOW);
39. for (j = 5;J < = 7;J++)
40. digitalWrite (j, LOW);
41. digitalWrite (dp, HIGH);
42. digitalWrite (f, HIGH);
43. digitalWrite (e, HIGH);
44. }
45. / / display digital 4
46. void digital_4 (void)
47. {
48. digitalWrite (c, LOW);
49. digitalWrite (b, LOW);
50. digitalWrite (f, LOW);
51. digitalWrite (g, LOW);
52. digitalWrite (dp, HIGH);
53. digitalWrite (a HIGH);
54. digitalWrite (e, HIGH);
55. digitalWrite (d, HIGH);
56. }
57. / / display digital 5
58. void digital_5 (void)
59. {
60. unsigned char j;
61. for (j = 7;J < = 9;J++)
62. digitalWrite (j, LOW);
63. digitalWrite (c, LOW);
64. digitalWrite (d, LOW);
65. digitalWrite (dp, HIGH);
66. digitalWrite (b, HIGH);
67. digitalWrite (e, HIGH);
68. }
69. / / display digital 6
70. void digital_6 (void)
71. {
72. unsigned char j;
73. for (j = 7;J < = 11;J++)
74. digitalWrite (j, LOW);
75. digitalWrite (c, LOW);
76. digitalWrite (dp, HIGH);
77. digitalWrite (b, HIGH);
78. }
79. / / display digital 7
80. void digital_7 (void)
81. {
82. unsigned char j;
83. for (j = 5;J < = 7;J++)
84. digitalWrite (j, LOW);
85. digitalWrite (dp, HIGH);
86. for (j = 8;J < = 11;J++)
87. digitalWrite (j, HIGH);
88. }
89. / / display digital 8
90. void digital_8 (void)
91. {
92. unsigned char j;
93. for (j = 5;J < = 11;J++)
94. digitalWrite (j, LOW);
95. digitalWrite (dp, HIGH);
96. }
97. void setup ()
98. {
99. int I;/ / define variables
100. for (I = 4;I < = 11;I++)
101. pinMode (I, the OUTPUT);/ / set 4 ~ 11 pins as output mode
102. }
103. void loop ()
104. {
105.while (1)
106. {
107. digital_1 ();/ / the digital 1
108. delay (2000);/ / delay 2 s
109. digital_2 ();
110. delay (2000);
111. digital_3 ();
112. delay (2000);
113. digital_4 ();
114. delay (2000);
115. digital_5 ();
116. delay (2000);
117. digital_6 ();
118. delay (2000);
119. digital_7 ();
120. delay (2000);
121. digital_8 ();
122. delay (2000);
123. }
124. }

The results of this test are shown in the loop of the digital tube 1, 2, 3, 4, 5, 6, 7, 8.

The code above uses the traditional method to display 1, 2, 3, 4. This approach is not appropriate when we have a large amount of work. Now we need to use the array method to control.Before using the array, the switch situation of each port should be counted according to the display of 0, 1, 2, 3, etc. The statistical results are as follows.

Control board pin
Serial number of digital tube
0
1
2
3
4
5
6
7
8
9
4
5(DP)
1
1
1
1
1
1
1
1
1
1
5
4(C)
0
0
1
0
0
0
0
0
0
0
6
6(B)
0
0
0
0
0
1
1
0
0
0
7
7(A)
0
1
0
0
1
0
0
0
0
0
8
9(F)
0
1
1
1
0
0
0
1
0
0
9
10(G)
1
1
0
0
0
0
0
1
0
0
10
1(E)
0
1
0
1
1
1
0
1
0
1
11
2(D)
0
1
0
0
1
0
0
1
0
0

Please input the following code into the control board, to see the effect of the experiment and then study the similarities and differences between two mode expressions.

ARDUINO code
1. byte seven_seg_digits [10 [8 = {/ / set the array of switches corresponding to each number
2. {0, 0, 0, 0, 0, 0}, / / = 0
3. {1, 0, 1, 1, 1, 1, 1}, / / = 1
4. {1, 0, 0, 0, 0, 0}, / / = 2
5. {0, 0, 0, 0, 1, 0}, / / = 3
6. {1, 0, 0, 0, 0, 1, 1}, / / = 4
7. {1,00, 0, 0, 0, 0, 1, 0}, / / = 5
8. {0, 0, 0, 0, 0, 0, 0}, / / = 6
9. {0, 0, 0, 1, 1, 1, 1}, / / = 7
10. {0, 0, 0, 0, 0, 0, 0, 0, 0}, / / = 8
11. {0, 0, 0, 0, 0, 1, 0, 0, 0, 1, 0} / / = 9
12. };
13. 
14. void setup () {/ 4-11 ports are set as output mode
15. pinMode (4, the OUTPUT);
16. pinMode (5, the OUTPUT);
17. pinMode (6, the OUTPUT);
18. pinMode (7, the OUTPUT);
19. pinMode (8, the OUTPUT);
20. pinMode (9, the OUTPUT);
21. pinMode (10, the OUTPUT);
22. pinMode (11, the OUTPUT);
23. }
24. 
25. void sevenSegWrite (byte digit) {/ / set to control the pin switch by array, in order 4-11 port
26. byte pin = 4;
27. for byte segCount = 0;SegCount < 8;+ + segCount) {
28. digitalWrite (pin, seven_seg_digits [digit [segCount);
29. + + pin;
30. }
31. }
32. 
33. void loop () {/ / set the display effect to count down from 9
34. for (byte count = 10;The count > 0;- count) {
35. delay (1000);
36. sevenSegWrite (count - 1);
37. }
38. delay (2000);

评论

此博客中的热门博文

21. Arduino learning notebook-- Experiment of controlling steering engine

20.Arduino learning notebook--Use Arduino Duemilanove to download the bootloader to other chips

19.Arduino learning notebook--Atmega8 makes the minimum arduino system