Following on from the LCD 4484 shield introduction, we will present some more basic examples using this shield
This is another example using the LCD4484 shield, this time put a character on the screen and then move it across the screen.
Code
[c]
#include “LCD4884.h”
void setup()
{
//initialise and clear
lcd.LCD_init();
lcd.LCD_clear();
}
void loop()
{
char line=0, pos=0;
//clear the LCD
lcd.LCD_clear();
//pause for 1 second
delay(1000);
//go to position 0,0
lcd.LCD_set_XY(pos,line);
//loop until x position is 55
while (pos<=55)
{
//move to LCD position
lcd.LCD_set_XY(pos,line);
//write a character to LCD
lcd.LCD_prop_write_char(‘a', MENU_NORMAL);
//increment by 1
pos++;
//pause for 100 milliseconds
delay(100);
}
//1 second delay
delay(1000);
}
[/c]
Display a character on the display in a random location.
Code
[c]
#include “LCD4884.h”
void setup()
{
//initialise and clear
Serial.begin(9600);
// if analog input pin 0 is unconnected, random analog
// noise will cause the call to randomSeed() to generate
// different seed numbers each time the sketch runs.
// randomSeed() will then shuffle the random function.
randomSeed(analogRead(0));
lcd.LCD_init();
lcd.LCD_clear();
}
void loop()
{
long randomX, randomY;
//random number between 0 and 84
randomX = random(0,84);
//random number between 0 and 4
randomY = random(0,4);
//clear the LCD
lcd.LCD_clear();
//pause for 1 second
delay(1000);
//move to LCD position
lcd.LCD_set_XY(randomX,randomY);
//write a character to LCD
lcd.LCD_prop_write_char(‘a', MENU_NORMAL);
//1 second delay
delay(1000);
}
[/c]
Flash the backlight and display lines of text
[c]
#include
int delayValue=200;
void setup()
{
lcd.LCD_init(); // creates instance of LCD
lcd.LCD_clear(); // blank the display
pinMode(7, OUTPUT);
}
void loop()
{
//flash the back light
for (int a=0; a<5; a++)
{
digitalWrite(7, LOW);
delay(delayValue);
digitalWrite(7, HIGH);
delay(delayValue);
}
//fill every line with sample text
for (int a=0; a<6; a++)
{
lcd.LCD_write_string(0,a,"01234567980123", MENU_NORMAL); // ignore MENU_NORMAL for now
delay(delayValue);
}
delay(delayValue);
}
[/c]
Write big numbers on the LCD
[c]
#include
void setup()
{
lcd.LCD_init(); // creates instance of LCD
lcd.LCD_clear(); // blank the display
pinMode(7, OUTPUT);
}
void loop()
{
//flash the back light
lcd.LCD_write_string_big(0, 0, “012345”, MENU_NORMAL);
lcd.LCD_write_string_big(0, 3, “67890”, MENU_NORMAL);
delay(1000);
}
[/c]
Links
Amazon US link – SainSmart Graphic LCD4884 Shield for Arduino
Amazon UK link – ATmega2560 + Graphic LCD4884 Shield for Arduino