Skip to content

Instantly share code, notes, and snippets.

@edenwaith
Created November 27, 2018 01:25
Show Gist options
  • Select an option

  • Save edenwaith/4637830c0887b9b3a62c5f340dee22a0 to your computer and use it in GitHub Desktop.

Select an option

Save edenwaith/4637830c0887b9b3a62c5f340dee22a0 to your computer and use it in GitHub Desktop.
Take input from the keyboard and print it to a 16x2 LCD display.
#include <LiquidCrystal.h>
// LiquidCrystal display with:
// rs on pin 12
// rw on pin 11
// enable on pin 10
// d4-7 on pins 5 - 2
// LiquidCrystal lcd(12, 11, 10, 5, 4, 3, 2);
// LiquidCrystal lcd(12, 11, 5, 4, 3, 2);
// Per https://www.hobbyist.co.nz/?q=16x2-arduino-lcd-shield,
LiquidCrystal lcd(8,9,4,5,6,7);
void setup() {
// put your setup code here, to run once:
Serial.begin(9600);
lcd.begin(2, 20);
// lcd.begin(16, 2);
lcd.clear();
lcd.setCursor(0, 0);
lcd.print("Evil Genius");
lcd.setCursor(0, 1);
lcd.print("Rules");
}
void loop() {
// put your main code here, to run repeatedly:
if (Serial.available())
{
char ch = Serial.read();
if (ch == '#')
{
lcd.clear();
}
else if (ch == '/')
{
lcd.setCursor(0,1);
}
else
{
lcd.write(ch);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment