15.Arduino learning notebook--Liquid crystal experiment of 12864

15.Arduino learning notebook--Liquid crystal experiment of 12864

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

12864 is the lattice abbreviation of the 128*64 lattice liquid crystal module.
Control chip generally adopts ST7920 or is compatible with it.
The data bus adopts the way of 8-bit parallel port and SPI serial port.
The 12864 LCD zip font version with no font version.
Font version does not need to enter again after the Chinese characters are became lattice with lattice generator, directly input the Chinese character interior code can show the corresponding Chinese characters. No font version wants to display Chinese characters, it only can be driven by its own way according to the lattice.
The 12864 LCD is shown below.


The diagram below shows the hardware connection diagram of the arduino connection mode and the 12864 LCD







The code of SPI connection mode driver
ARDUINO code
1. / *
2. LCD Arduino
3. PIN1 = GND
4. PIN2 = 5 v
5. RS (CS) = 8;
6. RW (SID) = 9;
7. EN (CLK) = 3;
8. PIN15 PSB = GND;
9. * /
10. 
11. # include "LCD12864RSPI. H"
12. #define AR_SIZE(a) sizeof (a)/sizeof (a)
13. 
14. unsigned char show0 [= {XBF XBC 0, 0 xab, 0, 0 XCD, 0 xb9, 0 xa4, 0 xb7, 0 XBB}; / / geek workshop
15. unsigned char show1 [= "geek - workshop";
16. unsigned char logo0 [= {/ / smiling face
17.       0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
18.       0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
19.       0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
20.       0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
21.       0x00,0x00,0x00,0x00,0x00,0x00,0x01,0xFF,
22.       0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
23.       0x00,0x00,0x00,0x00,0x00,0x00,0x1F,0xFF,
24.       0xF8,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
25.       0x00,0x00,0x00,0x00,0x00,0x00,0xFF,0xFF,
26.       0xFF,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
27.       0x00,0x00,0x00,0x00,0x00,0x03,0xFE,0x00,
28.       0x7F,0xC0,0x00,0x00,0x00,0x00,0x00,0x00,
29.       0x00,0x00,0x00,0x00,0x00,0x0F,0xF0,0x00,
30.       0x0F,0xF0,0x00,0x00,0x00,0x00,0x00,0x00,
31.       0x00,0x00,0x00,0x00,0x00,0x1F,0x80,0x00,
32.       0x01,0xF8,0x00,0x00,0x00,0x00,0x00,0x00,
33.       0x00,0x00,0x00,0x00,0x00,0x3E,0x00,0x00,
34.       0x00,0x7C,0x00,0x00,0x00,0x00,0x00,0x00,
35.       0x00,0x00,0x00,0x00,0x00,0xF8,0x00,0x00,
36.       0x00,0x1F,0x00,0x00,0x00,0x00,0x00,0x00,
37.       0x00,0x00,0x00,0x00,0x01,0xF0,0x00,0x00,
38.       0x00,0x0F,0x80,0x00,0x00,0x00,0x00,0x00,
39.      0x00,0x00,0x00,0x00,0x03,0xE0,0x00,0x00,
40.       0x00,0x07,0xC0,0x00,0x00,0x00,0x00,0x00,
41.       0x00,0x00,0x00,0x00,0x07,0xC0,0x00,0x00,
42.       0x00,0x01,0xE0,0x00,0x00,0x00,0x00,0x00,
43.       0x00,0x00,0x00,0x00,0x07,0x80,0x00,0x00,
44.       0x00,0x00,0xE0,0x00,0x00,0x00,0x00,0x00,
45.       0x00,0x00,0x00,0x00,0x0F,0x00,0x00,0x00,
46.       0x00,0x00,0xF0,0x00,0x00,0x00,0x00,0x00,
47.       0x00,0x00,0x00,0x00,0x1E,0x00,0x00,0x00,
48.       0x00,0x00,0x78,0x00,0x00,0x00,0x00,0x00,
49.       0x00,0x00,0x00,0x00,0x3C,0x00,0x00,0x00,
50.       0x00,0x00,0x3C,0x00,0x00,0x00,0x00,0x00,
51.       0x00,0x00,0x00,0x00,0x38,0x00,0x40,0x00,
52.       0x00,0x80,0x1C,0x00,0x00,0x00,0x00,0x00,
53.       0x00,0x00,0x00,0x00,0x78,0x03,0xF8,0x00,
54.       0x07,0xF0,0x1E,0x00,0x00,0x00,0x00,0x00,
55.       0x00,0x00,0x00,0x00,0x70,0x07,0xFE,0x00,
56.       0x0F,0xFC,0x0E,0x00,0x00,0x00,0x00,0x00,
57.       0x00,0x00,0x00,0x00,0xF0,0x1F,0xBF,0x00,
58.       0x3F,0x7E,0x0F,0x00,0x00,0x00,0x00,0x00,
59.       0x00,0x00,0x00,0x00,0xE0,0x3E,0x0F,0x80,
60.       0x7C,0x1F,0x07,0x00,0x00,0x00,0x00,0x00,
61.       0x00,0x00,0x00,0x00,0xE0,0x7C,0x07,0xC0,
62.       0xF8,0x0F,0x87,0x00,0x00,0x00,0x00,0x00,
63.       0x00,0x00,0x00,0x01,0xE0,0xF8,0x01,0xE1,
64.       0xF0,0x03,0xC3,0x80,0x00,0x00,0x00,0x00,
65.       0x00,0x00,0x00,0x01,0xC0,0xF0,0x01,0xE1,
66.       0xE0,0x03,0xC3,0x80,0x00,0x00,0x00,0x00,
67.       0x00,0x00,0x00,0x01,0xC0,0xE0,0x00,0xE1,
68.       0xC0,0x01,0xC3,0x80,0x00,0x00,0x00,0x00,
69.       0x00,0x00,0x00,0x01,0xC0,0x00,0x00,0x00,
70.       0x00,0x00,0x03,0x80,0x00,0x00,0x00,0x00,
71.       0x00,0x00,0x00,0x03,0x80,0x00,0x00,0x00,
72.       0x00,0x00,0x01,0xC0,0x00,0x00,0x00,0x00,
73.       0x00,0x00,0x00,0x03,0x80,0x00,0x00,0x00,
74.       0x00,0x00,0x01,0xC0,0x00,0x00,0x00,0x00,
75.       0x00,0x00,0x00,0x03,0x80,0x00,0x00,0x00,
76.       0x00,0x00,0x01,0xC0,0x00,0x00,0x00,0x00,
77.       0x00,0x00,0x00,0x03,0x80,0x00,0x00,0x00,
78.       0x00,0x00,0x01,0xC0,0x00,0x00,0x00,0x00,
79.       0x00,0x00,0x00,0x03,0x80,0x00,0x00,0x00,
80.       0x00,0x00,0x01,0xC0,0x00,0x00,0x00,0x00,
81.       0x00,0x00,0x00,0x03,0x80,0x00,0x00,0x00,
82.       0x00,0x00,0x01,0xC0,0x00,0x00,0x00,0x00,
83.       0x00,0x00,0x00,0x03,0x80,0x00,0x00,0x00,
84.       0x00,0x00,0x01,0xC0,0x00,0x00,0x00,0x00,
85.       0x00,0x00,0x00,0x03,0x80,0x00,0x00,0x00,
86.       0x00,0x00,0x01,0xC0,0x00,0x00,0x00,0x00,
87.       0x00,0x00,0x00,0x03,0x80,0x00,0x00,0x00,
88.       0x00,0x00,0x01,0xC0,0x00,0x00,0x00,0x00,
89.       0x00,0x00,0x00,0x03,0x80,0x00,0x00,0x00,
90.       0x00,0x00,0x01,0xC0,0x00,0x00,0x00,0x00,
91.       0x00,0x00,0x00,0x01,0xC0,0x00,0x00,0x00,
92.       0x00,0x00,0x01,0x80,0x00,0x00,0x00,0x00,
93.       0x00,0x00,0x00,0x01,0xC0,0x00,0x00,0x00,
94.       0x00,0x00,0x03,0x80,0x00,0x00,0x00,0x00,
95.       0x00,0x00,0x00,0x01,0xC0,0x00,0x00,0x00,
96.       0x00,0x00,0x03,0x80,0x00,0x00,0x00,0x00,
97.       0x00,0x00,0x00,0x01,0xE0,0x00,0x00,0x00,
98.       0x00,0x00,0x03,0x80,0x00,0x00,0x00,0x00,
99.       0x00,0x00,0x00,0x00,0xE0,0x00,0x00,0x00,
100.       0x00,0x00,0x07,0x00,0x00,0x00,0x00,0x00,
101.       0x00,0x00,0x00,0x00,0xE0,0x00,0x00,0x00,
102.       0x00,0x00,0x07,0x00,0x00,0x00,0x00,0x00,
103.       0x00,0x00,0x00,0x00,0xF0,0x00,0x0C,0x00,
104.       0x0C,0x00,0x0F,0x00,0x00,0x00,0x00,0x00,
105.       0x00,0x00,0x00,0x00,0x70,0x00,0x1E,0x00,
106.       0x1E,0x00,0x0E,0x00,0x00,0x00,0x00,0x00,
107.       0x00,0x00,0x00,0x00,0x78,0x00,0x1F,0x00,
108.       0x3E,0x00,0x1E,0x00,0x00,0x00,0x00,0x00,
109.       0x00,0x00,0x00,0x00,0x38,0x00,0x07,0x80,
110.       0xF8,0x00,0x1C,0x00,0x00,0x00,0x00,0x00,
111.       0x00,0x00,0x00,0x00,0x3C,0x00,0x03,0xE1,
112.       0xF0,0x00,0x3C,0x00,0x00,0x00,0x00,0x00,
113.       0x00,0x00,0x00,0x00,0x1E,0x00,0x01,0xFF,
114.       0xE0,0x00,0x78,0x00,0x00,0x00,0x00,0x00,
115.       0x00,0x00,0x00,0x00,0x0F,0x00,0x00,0xFF,
116.       0x80,0x00,0xF0,0x00,0x00,0x00,0x00,0x00,
117.       0x00,0x00,0x00,0x00,0x07,0x00,0x00,0x3F,
118.       0x00,0x00,0xF0,0x00,0x00,0x00,0x00,0x00,
119.       0x00,0x00,0x00,0x00,0x07,0x80,0x00,0x00,
120.       0x00,0x01,0xE0,0x00,0x00,0x00,0x00,0x00,
121.       0x00,0x00,0x00,0x00,0x03,0xE0,0x00,0x00,
122.       0x00,0x07,0xC0,0x00,0x00,0x00,0x00,0x00,
123.       0x00,0x00,0x00,0x00,0x01,0xF0,0x00,0x00,
124.       0x00,0x0F,0x80,0x00,0x00,0x00,0x00,0x00,
125.       0x00,0x00,0x00,0x00,0x00,0xF8,0x00,0x00,
126.       0x00,0x1F,0x00,0x00,0x00,0x00,0x00,0x00,
127.       0x00,0x00,0x00,0x00,0x00,0x3E,0x00,0x00,
128.       0x00,0x7E,0x00,0x00,0x00,0x00,0x00,0x00,
129.       0x00,0x00,0x00,0x00,0x00,0x1F,0x80,0x00,
130.       0x01,0xF8,0x00,0x00,0x00,0x00,0x00,0x00,
131.       0x00,0x00,0x00,0x00,0x00,0x0F,0xE0,0x00,
132.       0x07,0xF0,0x00,0x00,0x00,0x00,0x00,0x00,
133.       0x00,0x00,0x00,0x00,0x00,0x03,0xFE,0x00,
134.       0x3F,0xC0,0x00,0x00,0x00,0x00,0x00,0x00,
135.       0x00,0x00,0x00,0x00,0x00,0x00,0xFF,0xFF,
136.       0xFF,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
137.      0x00,0x00,0x00,0x00,0x00,0x00,0x1F,0xFF,
138.      0xF8,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
139.       0x00,0x00,0x00,0x00,0x00,0x00,0x01,0xFF,
140.      0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
141.       0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
142.       0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
143.       0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
144.       0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
145. };
146. 
147. void setup ()
148. {
149. LCDA. Initialise ();// screen initialization
150. Delay (100);
151. }
152. 
153. void loop ()
154. {
155. LCDA. The CLEAR ();/ / clear screen
156. delay (100);
157. LCDA. DisplayString (0, 2, show0 AR_SIZE (show0));// start from the third row of the first line ,showing the word geek-workshop
158. delay (100);
159. LCDA. DisplayString (2, 1, show1 AR_SIZE (show1);;// start from the second row of the third line, showing with the word geek-workshop
160. delay (5000);
161. LCDA. The CLEAR ();/ / clear screen
162. delay (100);
163. LCDA. DrawFullScreen (logo0);
164. delay (5000);
165. }

Firstly, introduce how to find the output characters code, open Chinese character interior code after transforming in the software. Click on the transformation will show the corresponding code of different Chinese characters. For example, the corresponding code of "ji()" is BCAB, then the code is divided into two segments send to the 12864 LCD, 0 XBC xab with 0. So that it can show the character ji().



Generally, after using SPI method, I seldom use 8 bits, because there are too many ports, but I still put them out for you to learn.
The hardware connection diagram






The following is the 8-bit code, using the library file.
ARDUINO code

1. / *
2. LCD Arduino
3. RS = 17; Analog to responsible
4. RW = 16; Analog Pin2
5. EN = 18; Analog Pin4
6. D0 = 8;
7. D1 = 9;
8. D2 = 10;
9. D3 = 11;
10. D4 = 4;
11. D5 = 5;
12. D6 = 6;
13. D7 = 7.
14. PIN15 PSB = 5 v.
15. * /
16. 
17. # include "LCD12864R. H"
18. #define AR_SIZE(a) sizeof (a)/sizeof (a)
19. 
20. unsigned char show0 [= {XBF XBC 0, 0 xab, 0, 0 XCD, 0 xb9, 0 xa4, 0 xb7, 0 XBB}; / / geek workshop
21. unsigned char show1 [= "geek - workshop";
22. 
23. void setup ()
24. {
25. LCDA. Initialise ();// screen initialization
26. delay (100);
27. }
28. 
29. void loop ()
30. {
31. LCDA. The CLEAR ();/ / clear screen
32. delay (100);
33. LCDA. DisplayString (0, 2, show0 AR_SIZE (show0));// the first line of the first line begins, showing the word geek workshop
34. delay (100);
35. LCDA. DisplayString (2, 1, show1 AR_SIZE (show1);;// the second row of the third line starts with the word geek-workshop
36. While (1);
37. }



Contact me: michelle1273110435@gmail.com

The other blog


评论

此博客中的热门博文

9.Arduino learning notebook--Photocontrolled LED experiment

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

17.Arduino learning notebook - stepper motors experiment