User Tools

Site Tools


tutorials:learn:lcd:charlcd.html

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
Next revision Both sides next revision
tutorials:learn:lcd:charlcd.html [2011/07/15 21:41]
dogstar49
tutorials:learn:lcd:charlcd.html [2011/12/29 22:24]
ladyada [BONUS! making your OWN character]
Line 96: Line 96:
 [[http://​www.ladyada.net/​images/​arduino/​lcdtut/​bbpower.jpg|{{ ​ http://​www.ladyada.net/​images/​arduino/​lcdtut/​bbpower_t.jpg?​nolink&​500x375 ​ |}}]] [[http://​www.ladyada.net/​images/​arduino/​lcdtut/​bbpower.jpg|{{ ​ http://​www.ladyada.net/​images/​arduino/​lcdtut/​bbpower_t.jpg?​nolink&​500x375 ​ |}}]]
  
-Next we'll connect up the backlight for the LCD. Connect pin 16 to ground and pin 15 to +5V+Next we'll connect up the backlight for the LCD. Connect pin 16 to ground and pin 15 to +5V through a series resistor. To calculate the value of the series resistor, look up the maximum backlight current and the typical backlight voltage drop from the data sheet. Subtract the voltage drop from 5 volts, then divide by the maximum current, then round up to the next standard resistor value. For example, if the backlight voltage drop is 3.5v typical and the rated current is 16mA, then the resistor should be (5 - 3.5)/0.016 = 93.75 ohms, or 100 ohms when rounded up to a standard value. If you can't find the data sheet, then it should be safe to use a 220 ohm resistor, although a value this high may make the backlight rather dim.
  
 [[http://​www.ladyada.net/​images/​arduino/​lcdtut/​backlitepower.jpg|{{ ​ http://​www.ladyada.net/​images/​arduino/​lcdtut/​backlitepower_t.jpg?​nolink&​500x375 ​ |}}]] [[http://​www.ladyada.net/​images/​arduino/​lcdtut/​backlitepower.jpg|{{ ​ http://​www.ladyada.net/​images/​arduino/​lcdtut/​backlitepower_t.jpg?​nolink&​500x375 ​ |}}]]
Line 113: Line 113:
  
 [[http://​www.ladyada.net/​images/​arduino/​lcdtut/​potplace.jpg|{{ ​ http://​www.ladyada.net/​images/​arduino/​lcdtut/​potplace_t.jpg?​nolink&​500x382 ​ |}}]] [[http://​www.ladyada.net/​images/​arduino/​lcdtut/​potplace.jpg|{{ ​ http://​www.ladyada.net/​images/​arduino/​lcdtut/​potplace_t.jpg?​nolink&​500x382 ​ |}}]]
- 
-New Haven Displays [[http://​www.newhavendisplay.com/​index.php?​main_page=index&​cPath=119_576]] have recently released some character OLED displays which have the same 16 pin interface. ​ The OLED displays do not require the contrast potentiometer. 
  
 Connect one side of the pot to +5V and the other to Ground (it doesn'​t matter which goes on what side). The middle of the pot (wiper) connects to pin 3 Connect one side of the pot to +5V and the other to Ground (it doesn'​t matter which goes on what side). The middle of the pot (wiper) connects to pin 3
Line 274: Line 272:
 [[http://​www.ladyada.net/​images/​arduino/​lcdtut/​longmessage2.jpg|{{ ​ http://​www.ladyada.net/​images/​arduino/​lcdtut/​longmessage2_t.jpg?​nolink&​500x375 ​ |}}]] [[http://​www.ladyada.net/​images/​arduino/​lcdtut/​longmessage2.jpg|{{ ​ http://​www.ladyada.net/​images/​arduino/​lcdtut/​longmessage2_t.jpg?​nolink&​500x375 ​ |}}]]
  
 +==== RGB backlight LCDs ====
 +
 +[[http://​www.adafruit.com/​category/​63|We now stock a few different RGB backlight LCDs]]. These LCDs work just like the normal character type, but the backlight has three LEDS (red/​green/​blue) so you can generate any color you'd like. Very handy when you want to have some ambient information conveyed.
 +
 +After you've wired up the LCD and tested it as above, you can connect the LEDs to the PWM analog out pins of the Arduino to precisely set the color. The PWM pins are fixed in hardware and there'​s 6 of them but three are already used so we'll use the remaining three PWM pins. Connect the red LED pin to Digital 3, the green LED pin (pin 17 of the LCD) to digital 5 and the blue LED pin (pin 18 of the LCD) to digital 6. You do not need any resistors between the LED pins and the arduino pins because resistors are already soldered onto the character LCD for you!
 +
 +{{  http://​www.ladyada.net/​images/​lcd/​rgblcdtest_t.jpg?​nolink&​500 ​ |}}
 +
 +Now upload this code to your Arduino to see the LCD background light swirl! ([[http://​www.flickr.com/​photos/​adafruit/​6002862732/​|Click here to see what it looks like in action]])
 +
 +{{ flickrvid>​6002862732 }}
 +
 +<code C>
 +
 +// include the library code:
 +#include <​LiquidCrystal.h>​
 +#include <​Wire.h> ​
 +
 +#define REDLITE 3
 +#define GREENLITE 5
 +#define BLUELITE 6
 +
 +// initialize the library with the numbers of the interface pins
 +LiquidCrystal lcd(7, 8, 9, 10, 11, 12);
 +
 +// you can change the overall brightness by range 0 -> 255
 +int brightness = 255;
 +
 +void setup() {
 +  // set up the LCD's number of rows and columns: ​
 +  lcd.begin(16,​ 2);
 +  // Print a message to the LCD.
 +  lcd.print("​RGB 16x2 Display ​ ");
 +  lcd.setCursor(0,​1);​
 +  lcd.print("​ Multicolor LCD ");
 +
 +  brightness = 100;
 +}
 +
 +
 +void loop() {
 +  for (int i = 0; i < 255; i++) {
 +    setBacklight(i,​ 0, 255-i);
 +    delay(5);
 +  }
 +  for (int i = 0; i < 255; i++) {
 +    setBacklight(255-i,​ i, 0);
 +    delay(5);
 +  }
 +  for (int i = 0; i < 255; i++) {
 +    setBacklight(0,​ 255-i, i);
 +    delay(5);
 +  }
 +}
 +
 +
 +
 +void setBacklight(uint8_t r, uint8_t g, uint8_t b) {
 +  // normalize the red LED - its brighter than the rest!
 +  r = map(r, 0, 255, 0, 100);
 +  g = map(g, 0, 255, 0, 150);
 +
 +  r = map(r, 0, 255, 0, brightness);​
 +  g = map(g, 0, 255, 0, brightness);​
 +  b = map(b, 0, 255, 0, brightness);​
 +
 +  // common anode so invert!
 +  r = map(r, 0, 255, 255, 0);
 +  g = map(g, 0, 255, 255, 0);
 +  b = map(b, 0, 255, 255, 0);
 +  Serial.print("​R = "); Serial.print(r,​ DEC);
 +  Serial.print("​ G = "); Serial.print(g,​ DEC);
 +  Serial.print("​ B = "); Serial.println(b,​ DEC);
 +  analogWrite(REDLITE,​ r);
 +  analogWrite(GREENLITE,​ g);
 +  analogWrite(BLUELITE,​ b);
 +}
 +</​code>​
  
 ==== BONUS! making your OWN character ​ ==== ==== BONUS! making your OWN character ​ ====
Line 282: Line 358:
 {{  http://​www.ladyada.net/​images/​thermocouple/​thermolcd_t.jpg?​nolink&​500x385 ​ |}} {{  http://​www.ladyada.net/​images/​thermocouple/​thermolcd_t.jpg?​nolink&​500x385 ​ |}}
  
-You can do that with the **createChar** command, and to help you out [[http://icontexto.com/charactercreator/​|we're going to point you to this really great website that does the hard work for you!]]+You can do that with the **createChar** command, and to help you out [[http://www.quinapalus.com/hd44780udg.html|we're going to point you to this really great website that does the hard work for you!]]
  
  
/home/ladyada/public_html/wiki/data/pages/tutorials/learn/lcd/charlcd.html.txt · Last modified: 2016/01/28 18:05 (external edit)