Created
July 15, 2017 17:18
-
-
Save imorte/78ad89be2249dde9a675106a77740e61 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /* | |
| LiquidCrystal Library - Custom Characters | |
| Demonstrates how to add custom characters on an LCD display. | |
| The LiquidCrystal library works with all LCD displays that are | |
| compatible with the Hitachi HD44780 driver. There are many of | |
| them out there, and you can usually tell them by the 16-pin interface. | |
| This sketch prints "I <heart> Arduino!" and a little dancing man | |
| to the LCD. | |
| 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) | |
| * 10K poterntiometer on pin A0 | |
| created 21 Mar 2011 | |
| by Tom Igoe | |
| modified 11 Nov 2013 | |
| by Scott Fitzgerald | |
| Based on Adafruit's example at | |
| https://github.com/adafruit/SPI_VFD/blob/master/examples/createChar/createChar.pde | |
| This example code is in the public domain. | |
| http://www.arduino.cc/en/Tutorial/LiquidCrystal | |
| Also useful: | |
| http://icontexto.com/charactercreator/ | |
| */ | |
| // include the library code: | |
| #include <LiquidCrystal.h> | |
| LiquidCrystal lcd(12, 11, 5, 4, 3, 2); | |
| byte armsDown[8] = { | |
| 0b00100, | |
| 0b01010, | |
| 0b00100, | |
| 0b00100, | |
| 0b01110, | |
| 0b10101, | |
| 0b00100, | |
| 0b01010 | |
| }; | |
| byte armsUp[8] = { | |
| 0b00100, | |
| 0b01010, | |
| 0b00100, | |
| 0b10101, | |
| 0b01110, | |
| 0b00100, | |
| 0b00100, | |
| 0b01010 | |
| }; | |
| void setup() { | |
| Serial.begin(9600); | |
| lcd.createChar(0, heart); | |
| lcd.createChar(1, armsUp); | |
| lcd.createChar(2, armsDown); | |
| lcd.begin(16, 2); | |
| lcd.clear(); | |
| lcd.print("I "); | |
| lcd.write(byte(0)); | |
| lcd.print(" ARDUINO"); | |
| } | |
| void loop() { | |
| delay(200); | |
| for(int i = 0; i < 16; i++) { | |
| farmsUp(i); | |
| } | |
| delay(200); | |
| for(int i = 0; i < 16; i++) { | |
| farmsDown(i); | |
| } | |
| } | |
| void farmsUp(int position) { | |
| lcd.setCursor(position, 1); | |
| lcd.write(byte(1)); | |
| } | |
| void farmsDown(int position) { | |
| lcd.setCursor(position, 1); | |
| lcd.write(byte(2)); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment