Offline
Newbie
Karma: 0
Posts: 8
|
 |
« Reply #54 on: January 03, 2013, 01:41:41 pm » |
Hey guys, finally got the sainsmart lcd2004 sheild wired up (5v,gnd, SDA(pin 20), SCL (pin 21)) into the mega2560. When I run the hello world code (which apprears in the examples section of the IDE) below (directly from the new LiquidCrystal v1.2.1) all it does is flash very dimly. If I unplug the SDA and SCL it lights up and is clearly getting power. Any ideas?
0x3F came from the I2C scanner program I ran. There are no errors compiling.
#include <Wire.h> #include <LiquidCrystal_I2C.h>
#define BACKLIGHT_PIN 21
LiquidCrystal_I2C lcd(0x3F); // Set the LCD I2C address
//LiquidCrystal_I2C lcd(0x3F, BACKLIGHT_PIN, POSITIVE); // Set the LCD I2C address
// Creat a set of new characters const uint8_t charBitmap[][8] = { { 0xc, 0x12, 0x12, 0xc, 0, 0, 0, 0 }, { 0x6, 0x9, 0x9, 0x6, 0, 0, 0, 0 }, { 0x0, 0x6, 0x9, 0x9, 0x6, 0, 0, 0x0 }, { 0x0, 0xc, 0x12, 0x12, 0xc, 0, 0, 0x0 }, { 0x0, 0x0, 0xc, 0x12, 0x12, 0xc, 0, 0x0 }, { 0x0, 0x0, 0x6, 0x9, 0x9, 0x6, 0, 0x0 }, { 0x0, 0x0, 0x0, 0x6, 0x9, 0x9, 0x6, 0x0 }, { 0x0, 0x0, 0x0, 0xc, 0x12, 0x12, 0xc, 0x0 } };
void setup() { int charBitmapSize = (sizeof(charBitmap ) / sizeof (charBitmap[0]));
// Switch on the backlight pinMode ( BACKLIGHT_PIN, OUTPUT ); digitalWrite ( BACKLIGHT_PIN, HIGH ); lcd.begin(20,4); // initialize the lcd
for ( int i = 0; i < charBitmapSize; i++ ) { lcd.createChar ( i, (uint8_t *)charBitmap ); }
lcd.home (); // go home lcd.print("Hello, ARDUINO "); lcd.setCursor ( 0, 1 ); // go to the next line lcd.print (" FORUM - fm "); delay ( 100000 ); }
void loop() { lcd.home (); // Do a little animation by writing to the same location for ( int i = 0; i < 4; i++ ) { for ( int j = 0; j < 20; j++ ) { lcd.print (char(random(7))); } lcd.setCursor ( 0, 1 ); } delay (2000);
}
|