usb plus serial backpack

Breakout boards, sensors, other Adafruit kits, etc.

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
Locked
User avatar
harvtech
 
Posts: 11
Joined: Sun Sep 29, 2013 8:22 pm

usb plus serial backpack

Post by harvtech »

I have assembled the backpack and mounted it on the back of the supplied 16x2 LCD with RGB backlight.
It works as expected with the code supplied in the tutorial obtained at http://learn.adafruit.com/usb-plus-serial-backpack.
However I do not understand the portion of the code that changes the backlight color included below.

Code: Select all

void loop() {
// adjust colors
for (red = 0; red < 255; red++) {
lcd.write(0xFE);
lcd.write(0xD0);
lcd.write(red);
lcd.write((uint8_t)0);
lcd.write(255 - red);
delay(10); // give it some time to adjust the backlight!
}
for (green = 0; green < 255; green++) {
lcd.write(0xFE);
lcd.write(0xD0);
lcd.write(255-green);
lcd.write(green);
lcd.write((uint8_t)0);
delay(10); // give it some time to adjust the backlight!
}
for (blue = 0; blue < 255; blue++) {
lcd.write(0xFE);
lcd.write(0xD0);
lcd.write((uint8_t)0);
lcd.write(255-blue);
lcd.write(blue);
delay(10); // give it some time to adjust the backlight!
}
}
I understand that the commands:
lcd.write(0xFE);
lcd.write(0xD0);
are required to set RGB backlight color. However what follows to actually specify the color needs further explanation.
Last edited by adafruit_support_bill on Mon Sep 30, 2013 6:27 am, edited 1 time in total.
Reason: Please use the 'code' button when submitting code

1chicagodave
 
Posts: 564
Joined: Wed Jun 19, 2013 3:35 am

Re: usb plus serial backpack

Post by 1chicagodave »

Does this help?

http://learn.adafruit.com/usb-plus-seri ... -reference
Set RGB Backlight Color - 0xFE 0xD0 - Sets the backlight to the red, green and blue component colors. The values of can range from 0 to 255 (one byte). This is saved to EEPROM

Code: Select all


lcd.write(0xFE);  // Tell backpack that a command is coming next
lcd.write(0xD0);  // Set backlight to the following values....
lcd.write(red);                    // RED VALUE (0-255)
lcd.write((uint8_t)0);            // GREEN VALUE (0-255)
lcd.write(255 - red);              // BLUE VALUE (0-255)

User avatar
harvtech
 
Posts: 11
Joined: Sun Sep 29, 2013 8:22 pm

Re: usb plus serial backpack

Post by harvtech »

Now I understand that following the command is one byte for each color in RGB order ranging in value from 0 to 255. That makes sense but it was not exactly spelled out that way in the command reference and there was no explanation in the example code. Thanks much for your explanation.

Locked
Please be positive and constructive with your questions and comments.

Return to “Other Products from Adafruit”