Arduino with graphic color LCD shield ARD GRAPH132 programmed in C.

Arduino picture There are on the shield pins marked with '*'. These pins are to be used.
PORTC/pin0 (analog): for joystick positions
PORTD/pin3 (digital): for GLCD backlight working set HIGH !
pin0 not used  pin1: reset  
pin2: CS chip select  pin3: DIO commands/data  pin5: CLK clock


First we have to put the voltage on pin3 of PORTD (on the picture in yellow), we do it on the first line in setup with:
pinMode(3, OUTPUT); digitalWrite(3, HIGH);
So we adjusted full contrast. In the next example we use PWM for adjusting the contrast more precise. For testing the display I have used a simple program drawing a diagonal line and the text "Hello World !".

We need a driver for ARD GRAPH132 with the interface IC Phillips PCF-8833. Therefore I have modified existing drivers for my needs, created a GLCD library in standard library and copied these 2 files into it. It provides us with following functions:

void LCDCommand(unsigned char data);
void LCDData(unsigned char data);
void LCDInit(void);
void LCDClear(int color);
void LCDSetPixel(int color, unsigned char x, unsigned char y);
void LCDSetLine(int x0, int y0, int x1, int y1, int color);
void LCDSetRect(int x0, int y0, int x1, int y1, unsigned char fill, int color);
void LCDPutStr(char *pString, int x, int y, int fColor, int bColor);


How a 2 byte - serial bit by bit transmision on the pins looks like:

serial transmision

TB: transmitted byte
SCE: CS pin,
SCLK: CLK pin,
SDIN: DIO pin (transmited byte bit by bit).
DC is data or command bit sent before the bits of transmitted byte go (command=0, data=1).
This protocol is applied in functions LCDCommand and LCDData of driver LCD_d.c.


Outputting text with LCDPutStr:
We use Font8x16 table. Every character is depictured as a matrix of 8x16 = 128 pixels.


We see on the shield also a micro-joystick, which can be used for all sort of actions. It is connected to analog input pin 0 (in the picture up green) and the program can identify which position was pressed (idle, middle, right, down, left, up), because pressing connects input pin 0 to different voltage values, obtained from a voltage divider, realised on the ARD GRAPH132 shield. This way the program recognizes the click position using only one analog pin. Voltage on pin0 without signal is 5V. Pressing the buttons from left to right I have measured on pin0 with a digital multimeter following values:

idle: 4.9V     middle: 3.6V     right: 2.4V     down: 1.6V     left: 0.7V     up: 0V

Writing, uploading and runing a little program reading pin0 of ADC portc. Pressing joystick placed on the LCD board gives following values and voltages:
idle: 1023 > 5.00V    middle: 744 > 3.64V    right: 505 > 2.47V    down: 331 > 1.62V    left: 144 > 0.70V    up: 0 > 0.00V

joystick voltage levels