کد:
/*
#
# Example code for LCD1602 LiquidCrystal
# Company : AftabRayaneh
# Website : http://shop.aftabrayaneh.com
# Editor : mohammad omidvar - max
# Date : 17.10.2013
# Version : 1.0
*/
/*
The circuit:
* LCD RS pin to digital pin 12
* LCD Enable pin to digital pin 11
* LCD D4 pin to digital pin 5
* LCD D5 pin to digital pin 4
* LCD D6 pin to digital pin 3
* LCD D7 pin to digital pin 2
* LCD R/W pin to ground
* 10K potentiometer:
* ends to +5V and ground
* wiper to LCD VO pin (pin 3)
*/
// include the library code:
#include <LiquidCrystal.h>
// initialize the library with the numbers of the interface pins
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);
// make some custom characters:
byte heart[8] = {
0b00000,
0b01010,
0b11111,
0b11111,
0b11111,
0b01110,
0b00100,
0b00000
};
byte armsDown[8] = {
0b00100,
0b01010,
0b00100,
0b00100,
0b01110,
0b10101,
0b00100,
0b01010
};
byte armsUp[8] = {
0b00100,
0b01010,
0b00100,
0b10101,
0b01110,
0b00100,
0b00100,
0b01010
};
void setup() {
// create a new character
lcd.createChar(0, heart);
// create a new character
lcd.createChar(1, armsDown);
// create a new character
lcd.createChar(2, armsUp);
// set up the lcd's number of columns and rows:
lcd.begin(16, 2);
// Print a message to the lcd.
lcd.print("I ");
lcd.write(byte(0));
lcd.print(" Arduino! ");
lcd.write(1);
lcd.setCursor(0,1);
lcd.print("Max");
}
void loop() {
lcd.setCursor(4, 1);
// draw the little man, arms down:
lcd.write(1);
delay(500);
lcd.setCursor(4, 1);
// draw him arms up:
lcd.write(2);
delay(500);
}