0

code for serial LCD
Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.

code for serial LCD

by emesine on Sun Feb 04, 2018 11:14 am

Hello,

I am using this item:

USB + Serial Backpack Kit with 16x2 RGB backlight positive LCD - Black on RGB

I am communicating with the device using TTL, from a pin on my metro mini, not through the serial port.

I would like to set the screen to red, at about 50% brightness. Can someone help me with a code that will do this? Thanks!

emesine
 
Posts: 2
Joined: Sun Feb 04, 2018 11:13 am

Re: code for serial LCD

by emesine on Sat Feb 10, 2018 1:38 pm

This works:

So the first line after the commands calling it to attention, tells the Red led to be on at 254 Full brightness.
The next line says green be off or as near to off as i can get. 1
Next line says blue off or 1

I simply called the value in 0-255 format and not hex. You need to call all 3 led’s or it won’t work.

So to control the backlight you need this code running in the loop with a delay


lcd.write(0xFE);
lcd.write(0xD0); // First 2 lines call the attention of the chip and tells it we are going to change the colour

lcd.write(254); // RED Change the next 3 lines to a value for the colour
lcd.write(1); //Green
lcd.write(1); //Blue

delay(500); // give it some time to adjust the backlight!




For Green
lcd.write(0xFE);
lcd.write(0xD0); // First 2 lines call the attention of the chip and tells it we are going to change the colour lcd.write(1); // RED Change the next 3 lines to a value for the colour
lcd.write(254); //Green
lcd.write(1); //Blue

For Blue
lcd.write(0xFE);
lcd.write(0xD0); // First 2 lines call the attention of the chip and tells it we are going to change the colour lcd.write(1); // RED Change the next 3 lines to a value for the colour
lcd.write(1); //Green
lcd.write(254); //Blue

emesine
 
Posts: 2
Joined: Sun Feb 04, 2018 11:13 am

Please be positive and constructive with your questions and comments.