Created
December 17, 2020 18:23
-
-
Save matiasmicheletto/c06ca2ae4fa7e66bdba8e368445bbf01 to your computer and use it in GitHub Desktop.
LCD 2004 I2C xmas message
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
#include <Wire.h> | |
#include "LiquidCrystal_I2C.h" | |
/* If address is not 0x27, then try 0x3F */ | |
LiquidCrystal_I2C lcd(0x27,20,4); | |
/* Custom characters */ | |
byte c0[8] = {0x00,0x00,0x00,0x00,0x01,0x03,0x07,0x0F}; | |
byte c1[8] = {0x04,0x0E,0x1F,0x1F,0x1F,0x1F,0x1F,0x1F}; | |
byte c2[8] = {0x00,0x00,0x00,0x00,0x10,0x18,0x1C,0x1E}; | |
byte c3[8] = {0x01,0x03,0x07,0x0F,0x1F,0x00,0x00,0x00}; | |
byte c4[8] = {0x1F,0x1F,0x1F,0x1F,0x1F,0x1F,0x1F,0x1F}; | |
byte c5[8] = {0x10,0x18,0x1C,0x1E,0x1F,0x00,0x00,0x00}; | |
// Star | |
byte c6[8] = {0x00,0x00,0x15,0x0E,0x1F,0x0E,0x15,0x04}; | |
// Spanish exclamation mark | |
byte ex[8] = {0x00,0x04,0x00,0x00,0x04,0x04,0x04,0x04}; | |
void setup() { | |
lcd.init(); | |
lcd.createChar(0, c0); | |
lcd.createChar(1, c1); | |
lcd.createChar(2, c2); | |
lcd.createChar(3, c3); | |
lcd.createChar(4, c4); | |
lcd.createChar(5, c5); | |
lcd.createChar(6, c6); | |
lcd.createChar(7, ex); | |
/*Draw left tree*/ | |
lcd.setCursor(1,0); | |
lcd.write(byte(6)); | |
lcd.setCursor(0,1); | |
lcd.write(byte(0)); | |
lcd.write(byte(1)); | |
lcd.write(byte(2)); | |
lcd.setCursor(0,2); | |
lcd.write(byte(3)); | |
lcd.write(byte(4)); | |
lcd.write(byte(5)); | |
/* Draw right tree */ | |
lcd.setCursor(18,0); | |
lcd.write(byte(6)); | |
lcd.setCursor(17,1); | |
lcd.write(byte(0)); | |
lcd.write(byte(1)); | |
lcd.write(byte(2)); | |
lcd.setCursor(17,2); | |
lcd.write(byte(3)); | |
lcd.write(byte(4)); | |
lcd.write(byte(5)); | |
/* Draw central text */ | |
lcd.setCursor(6,1); | |
lcd.write(byte(7)); | |
lcd.print("Feliz"); | |
lcd.setCursor(6,2); | |
lcd.print("Navidad!"); | |
} | |
void loop() { | |
/* Turn on and off lcd backlight with random frequency */ | |
lcd.backlight(); | |
delay(random(500, 3000)); | |
lcd.noBacklight(); | |
delay(random(500, 3000)); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment