Created
October 16, 2017 22:54
-
-
Save Maffsie/4d4b635cfb8db398bd0d2dfda2e3cc9d to your computer and use it in GitHub Desktop.
This file contains 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 <I2C_LCD.h> | |
/* | |
* ArduinoNano I2C_LCD | |
* GND <-> GND | |
* 5V <-> 5V | |
* A4 <-> SDA | |
* A5 <-> SCL | |
* By virtue of this being an I2C display, only two pins (aside from power) are needed | |
*/ | |
I2C_LCD lcd; | |
//Default i2c address for the Seeed I2C LCD 128x64 display | |
uint8_t I2C_LCD_ADDRESS = 0x51; | |
void setup() { | |
//Start i2c connection | |
Wire.begin(); | |
//Blank screen | |
lcd.CleanAll(WHITE); | |
//Set font to 6x8 black-on-white with auto-newline enabled | |
lcd.FontModeConf(Font_6x8, FM_ANL_AAA, BLACK_BAC); | |
//Set cursor to top-left of screen | |
lcd.CharGotoXY(0,0); | |
lcd.print("henlo user"); | |
//Go down a line | |
lcd.CharGotoXY(0,10); | |
delay(1500); | |
lcd.print("helllo you STINKY USER"); | |
//The above line took up two lines, so go down two | |
lcd.CharGotoXY(0,30); | |
delay(2000); | |
lcd.print("go eat a power button ugly"); | |
delay(5000); | |
//Clean up display for loop | |
lcd.CleanAll(WHITE); | |
lcd.CharGotoXY(0,0); | |
} | |
void loop() { | |
//Will print ad-finitum. Because of how the Seeed I2C LCD works, after this reaches the bottom of the screen | |
//if it keeps going then it will slowly corrupt the display state. Quite amusing to watch. | |
lcd.print("henlo "); | |
delay(1000); | |
} |
This file contains 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 "Nokia_5110.h" | |
/* | |
* NodeMCU 1.0 PCD8544 | |
* GND <-> GND | |
* 3v3 <-> VCC | |
* D4 <-> RST | |
* D6 <-> SCE | |
* D5 <-> D/C | |
* D3 <-> DN (MOSI) | |
* D8 <-> SCLK | |
* 3v3+330ohmResi <-> LED | |
*/ | |
// RST = Reset | |
#define RST D4 | |
// CE (sometimes labelled SCE) = Chip select | |
#define CE D6 | |
// DC (sometimes labelled D/C) = Display/Control toggle | |
#define DC D5 | |
// DIN (sometimes labelled DN(MOSI)) = Data Input | |
#define DIN D3 | |
//CLK (sometimes labelled SCLK) = Clock (MUST be wired to a PWM-capable pin) | |
#define CLK D8 | |
Nokia_5110 lcd = Nokia_5110(RST, CE, DC, DIN, CLK); | |
void setup() { | |
//Because almost all PCD8544 (aka Nokia 5110/Nokia 3310) LCDs are recycled from old phones | |
//Your minimum usable contrast may differ. 60 is the default, but you may wish to lower or raise it. | |
lcd.setContrast(55); | |
lcd.println("henlo user"); | |
delay(1500); | |
lcd.println("helllo you STINKY USER"); | |
delay(2000); | |
lcd.println("go eat a power button ugly"); | |
delay(5000); | |
//Clear screen | |
lcd.clear(); | |
} | |
void loop() { | |
//Will print ad-finitum. Once it reaches the bottom of the screen it will loop back round to the top. | |
lcd.print("henlo "); | |
delay(1000); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment