66
66
67
67
For example, to change the baud rate to 115200 send 124 followed by 18.
68
68
69
+
70
+ *********************************************
71
+ *****************Cursor position cheat sheet:
72
+ *********************************************
73
+
74
+ For the most part, it is pretty straight forward on how to control the cursor.
75
+ Be warned though, the "line" numbers are a little strange (0, 64, 20, 84).
76
+ There are four "parts" to the two commands needed.
77
+
78
+ First, the command character (254), simply write this with:
79
+
80
+ OpenLCD.write(254);
81
+
82
+ Second, a single write that consists of adding up three important numbers.
83
+
84
+ OpenLCD.write(changePosition + line + position);
85
+
86
+ changePosition never changes (haha), it is the command for the serLCD to know we want to change position. It is always 128.
87
+
88
+ Then the "line" number is either 0, 64, 20 or 84.
89
+
90
+ These correspond to each line like so:
91
+
92
+ Line 1 = 0
93
+ Line 2 = 64
94
+ Line 3 = 20
95
+ Line 4 = 84
96
+
97
+ Then the "position" is a number from 0-15 or 0-19 (depending on which screen you are using).
98
+
99
+ For the 16x2 models, you will only need to set line 1 or line 2, so here's an example:
100
+
101
+ Jump to line 1, position 9
102
+ OpenLCD.write(254); //Send command character
103
+ OpenLCD.write(128 + 64 + 9); //Change the position (128) of the cursor to 2nd row (64), position 9 (9)
104
+
105
+ On a 20x4 model, you can try all four lines. For example:
106
+
107
+ Jump to line 3, position 4
108
+ OpenLCD.write(254); //Send command character
109
+ OpenLCD.write(128 + 20 + 4); //Change the position (128) of the cursor to 3rd row (20), position 4 (4)
110
+
111
+ And another 20x4 example:
112
+
113
+ Jump to line 4, position 18
114
+ OpenLCD.write(254); //Send command character
115
+ OpenLCD.write(128 + 84 + 18); //Change the position (128) of the cursor to 4th line (84), position 18 (18)
116
+
69
117
*/
70
118
71
119
#include < SoftwareSerial.h>
@@ -79,7 +127,7 @@ void setup()
79
127
Serial.begin (9600 ); // Start serial communication at 9600 for debug statements
80
128
Serial.println (" OpenLCD Example Code" );
81
129
82
- OpenLCD.begin (115200 ); // Begin communication with OpenLCD
130
+ OpenLCD.begin (9600 ); // Begin communication with OpenLCD
83
131
84
132
// Send the reset command to the display - this forces the cursor to return to the beginning of the display
85
133
OpenLCD.write (' |' ); // Send setting character
0 commit comments