Home Code 3-wire Serial LCD Module to arduino

3-wire Serial LCD Module to arduino

by shedboy71

This is a 3-wire Serial LCD Module example connected to an Arduino uno, I bought this as part of a kit there was an Arduino Uno and a couple of different LCDs but I always had trouble getting this one working. Its a nice LCD

SCK -> PIN 13
CS -> PIN12
SID -> PIN11

Here is the pinout of the connector

LCD pinout

LCD pinout

There is a wiki page with some more info about the LCD

 

Image

twi lcd

twi lcd

Code

This example uses the https://code.google.com/p/u8glib/wiki/u8glib

[cpp]

#include <U8glib.h>

U8GLIB_ST7920_128X64 u8g(13, 11, 12, U8G_PIN_NONE);

void draw(void)
{
// graphic commands to redraw the complete screen should be placed here
u8g.setFont(u8g_font_unifont);
//u8g.setFont(u8g_font_osb21);
u8g.drawStr( 0, 10, “Hello World!”);
u8g.drawStr( 0, 22, “Hello World 2!”);
}

void setup(void)
{

// assign default color value
if ( u8g.getMode() == U8G_MODE_R3G3B2 ) {
u8g.setColorIndex(255); // white
}
else if ( u8g.getMode() == U8G_MODE_GRAY2BIT ) {
u8g.setColorIndex(3); // max intensity
}
else if ( u8g.getMode() == U8G_MODE_BW ) {
u8g.setColorIndex(1); // pixel on
}
else if ( u8g.getMode() == U8G_MODE_HICOLOR ) {
u8g.setHiColorByRGB(120,64,255);
}
}

void loop(void) {
// picture loop
u8g.firstPage();
do {
draw();
} while( u8g.nextPage() );

// rebuild the picture after some delay
delay(50);
}

[/cpp]

Share

You may also like