Testing OK
This commit is contained in:
78
LiquidCrystal/examples/HelloWorld_4bit/HelloWorld_4bit.pde
Normal file
78
LiquidCrystal/examples/HelloWorld_4bit/HelloWorld_4bit.pde
Normal file
@ -0,0 +1,78 @@
|
||||
#include <Wire.h>
|
||||
#include <LiquidCrystal.h>
|
||||
|
||||
|
||||
#define CONTRAST_PIN 9
|
||||
#define BACKLIGHT_PIN 7
|
||||
#define CONTRAST 110
|
||||
LiquidCrystal lcd(12, 11, 5, 4, 3, 2, BACKLIGH_PIN, POSITIVE );
|
||||
|
||||
|
||||
// Creat a set of new characters
|
||||
byte smiley[8] = {
|
||||
0b00000,
|
||||
0b00000,
|
||||
0b01010,
|
||||
0b00000,
|
||||
0b00000,
|
||||
0b10001,
|
||||
0b01110,
|
||||
0b00000
|
||||
};
|
||||
|
||||
byte armsUp[8] = {
|
||||
0b00100,
|
||||
0b01010,
|
||||
0b00100,
|
||||
0b10101,
|
||||
0b01110,
|
||||
0b00100,
|
||||
0b00100,
|
||||
0b01010
|
||||
};
|
||||
|
||||
byte frownie[8] = {
|
||||
0b00000,
|
||||
0b00000,
|
||||
0b01010,
|
||||
0b00000,
|
||||
0b00000,
|
||||
0b00000,
|
||||
0b01110,
|
||||
0b10001
|
||||
};
|
||||
|
||||
void setup()
|
||||
{
|
||||
Serial.begin ( 57600 );
|
||||
|
||||
// Switch on the backlight and LCD contrast levels
|
||||
pinMode(CONTRAST_PIN, OUTPUT);
|
||||
analogWrite ( CONTRAST_PIN, CONTRAST );
|
||||
|
||||
//lcd.setBacklightPin ( BACKLIGHT_PIN, POSITIVE );
|
||||
//lcd.setBacklight ( HIGH );
|
||||
lcd.backlight();
|
||||
|
||||
lcd.begin(16,2); // initialize the lcd
|
||||
|
||||
lcd.createChar (0, smiley); // load character to the LCD
|
||||
lcd.createChar (1, armsUp); // load character to the LCD
|
||||
lcd.createChar (2, frownie); // load character to the LCD
|
||||
|
||||
lcd.home (); // go home
|
||||
lcd.print("Hello, ARDUINO ");
|
||||
lcd.setCursor ( 0, 1 ); // go to the next line
|
||||
lcd.print (" FORUM - fm ");
|
||||
}
|
||||
|
||||
void loop()
|
||||
{
|
||||
// Do a little animation by writing to the same location
|
||||
lcd.setCursor ( 14, 1 );
|
||||
lcd.print (char(2));
|
||||
delay (200);
|
||||
lcd.setCursor ( 14, 1 );
|
||||
lcd.print ( char(0));
|
||||
delay (200);
|
||||
}
|
Reference in New Issue
Block a user