Hitchhikers Guide to run a i2c 16x2 LiquidCrystalDisplay
.
First, for all, and forever: All starships "Heart of Gold" goes to @sej7278:
He helped me out and without him I were totally lost.
- What do I need Challenge (to escape the earth)
- SainSmart IIC/I2C 1602 serial LCD module
- 2x 4,7K Ω resistor
- one gallon of Pan Galactic Gargle Blaster
.
- Wiring Challenge (to left the Vogon Flagship throught the air-lock)
You need 4 Wires to connect the display to your Core and one to connect the resistors with the i2c bus.
I´ll try to explain:
Important, these are not the correct 4,7K ohm resistors, only 1K Ohm!!! Do not try this. Pls, this is only a demonstration. I set up mine as a serial circuit 3,8K and 1K and it works. But it´s up to you, it´s your hardware and I´am absolutely not responsible for any damage on your core! But I think this is crystal clear. Get the right resistors to protect you from vogon poetry!
Yellow wire goes from D0 to SDA(lcd)
Purple wire goes from D1 to SCL(lcd)
White wire goes from GND to GND(lcd)
Red wire goes from VIM to VCC(LCD)
Second red wire for the red line of the breadboard.
2 4,7K ohm resistors set up to the red line of the breadboard
Here is an image from the backside of my LCD.
When things come to an end and you have to escape the well known Ravenous Bugblatter Beast of Traal, then try to rotate the poti on the i2c backpack. Contrast goes down and you can barely manage to save your poor life.
.
- I2C address Challenge (to get on board of the Heart of Gold)
I wrote another tutorial exactly about this, if you need to scan where your i2c bus is attached to, then use THIS thread.
.
- Library and Example Code Challenge (to finally get Trinity)
You now almost there. You can fly to the restaurant at the end of the universe with your girl. Think about without @sej7278 this trip would not have been possible. Again thank you and now go to:
Gist: LiquidCrystal_I2C SparkCore · GitHub
Copy and Paste it to the Cloud IDE and finally don´t forget to edit the line of your identified i2c adress from the last step:
lcd = new LiquidCrystal_I2C(0x27, 16, 2);
.
- Custom Characters Challenge (Secret Mission: Keep calm facing nuclear warheads from Magrathea)
So your LCD is running, then prepare to jump through the planets portal to meet your destiny. The 16x2 lcd have limited space. If you wrote "Temperature: " you have lost 13 chars in one line. Not pretty much space, eh? Yes that´s right but there is way to solve that. Custom Characters!
Meet the Custom Character Generator from omerk and design how you like it. New Firefox on OSx seems to have problems with this. Simple use a different browser. If you have your character designed copy the code. We need only the
byte customChar[8] = {0b......,} part
For a running example we need something like this:
// Custom Character
byte SparkChar[8] = { 0b00000,0b10101,0b01010,0b00100,0b11111,0b00100,0b01010,0b10101 };
void setup() {
lcd->createChar(0, SparkChar);
// Setup output, this could be also used in the loop() part
lcd->clear();
lcd->setCursor(4,0);
lcd->write((uint8_t)7);
lcd->setCursor(6,0 );
lcd->print("Core");
lcd->setCursor(12,0);
lcd->write((uint8_t)7);
lcd->setCursor(2,1);
lcd->print("DONT PANIC");
}
void loop() {
// Oh no, not again
}
May the Galaxy be with you!
Now you can drink your Pan Galactic Gargle Blaster and hang out with Marvin
Hope it helps somebody.
Cheers clyde