Skip to content

Commit 3f68ee6

Browse files
author
Pete Lewis
committed
adjusting serial backlight to show all three colors more clearly
The original example was kind of confusing in what it showed (always leaving blue ang green on 100% after a full cycle). This new loop shows each color individually from 0 - 50 - 100, and turns them all off at each new section.
1 parent c0a4ee7 commit 3f68ee6

File tree

1 file changed

+43
-4
lines changed

1 file changed

+43
-4
lines changed

firmware/Examples/Serial/Example4_Serial_Backlight/Example4_Serial_Backlight.ino

Lines changed: 43 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -108,16 +108,55 @@ void loop()
108108

109109
//The following green and blue backlight control only apply if you have an RGB backlight enabled LCD
110110

111-
//To control the green backlight:
111+
all_off(); // turn off all backlights - see function below
112+
113+
//Control green backlight
114+
Serial.println("Green backlight set to 51%");
115+
OpenLCD.write('|'); //Put LCD into setting mode
116+
OpenLCD.write(158 + 15); //Set green backlight amount to 51%
112117

118+
delay(2000);
119+
120+
//Control green backlight
121+
Serial.println("Green backlight set to 100%");
113122
OpenLCD.write('|'); //Put LCD into setting mode
114123
OpenLCD.write(158 + 29); //Set green backlight amount to 100%
115-
//OpenLCD.write(158 + 0); //Set green backlight amount to 0%
124+
125+
delay(2000);
126+
127+
all_off(); // turn off all backlights - see function below
116128

117-
//To control the blue backlight:
129+
//Control blue backlight
130+
Serial.println("Blue backlight set to 51%");
131+
OpenLCD.write('|'); //Put LCD into setting mode
132+
OpenLCD.write(188 + 15); //Set blue backlight amount to 51%
133+
134+
delay(2000);
135+
136+
//Control blue backlight
137+
Serial.println("Blue backlight set to 100%");
118138
OpenLCD.write('|'); //Put LCD into setting mode
119139
OpenLCD.write(188 + 29); //Set blue backlight amount to 100%
120-
//OpenLCD.write(188 + 0); //Set blue backlight amount to 0%
121140

141+
delay(2000);
142+
143+
all_off(); // turn off all backlights - see function below
144+
145+
}
146+
147+
void all_off(void)
148+
{
149+
// Set all colors to 0
150+
151+
OpenLCD.write('|'); //Put LCD into setting mode
152+
OpenLCD.write(128); //Set white/red backlight amount to 0%
153+
154+
OpenLCD.write('|'); //Put LCD into setting mode
155+
OpenLCD.write(158 + 0); //Set green backlight amount to 0%
156+
157+
OpenLCD.write('|'); //Put LCD into setting mode
158+
OpenLCD.write(188 + 0); //Set blue backlight amount to 0%
159+
160+
delay(2000);
122161
}
123162

0 commit comments

Comments
 (0)