/*
LiquidCrystal Library - Hello World
Demonstrates the use a 16x2 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 "Hello World!" to the LCD
and shows the time.
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
* LCD VSS pin to ground
* LCD VCC pin to 5V
* 10K resistor:
* ends to +5V and ground
* wiper to LCD VO pin (pin 3)
Library originally added 18 Apr 2008
by David A. Mellis
library modified 5 Jul 2009
by Limor Fried (http://www.ladyada.net)
example added 9 Jul 2009
by Tom Igoe
modified 22 Nov 2010
by Tom Igoe
modified 7 Nov 2016
by Arturo Guadalupi
This example code is in the public domain.
http://www.arduino.cc/en/Tutorial/LiquidCrystalHelloWorld
*/// include the library code:
#include<LiquidCrystal.h>// initialize the library by associating any needed LCD interface pin
// with the arduino pin number it is connected to
constintrs=12,en=11,d4=5,d5=4,d6=3,d7=2;LiquidCrystallcd(rs,en,d4,d5,d6,d7);voidsetup(){// set up the LCD's number of columns and rows:
lcd.begin(16,2);// Print a message to the LCD.
lcd.print("hello, world!");}voidloop(){// set the cursor to column 0, line 1
// (note: line 1 is the second row, since counting begins with 0):
lcd.setCursor(0,1);// print the number of seconds since reset:
lcd.print(millis()/1000);}
/*
LiquidCrystal Library - Autoscroll
Demonstrates the use a 16x2 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 demonstrates the use of the autoscroll()
and noAutoscroll() functions to make new text scroll or not.
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 resistor:
* ends to +5V and ground
* wiper to LCD VO pin (pin 3)
Library originally added 18 Apr 2008
by David A. Mellis
library modified 5 Jul 2009
by Limor Fried (http://www.ladyada.net)
example added 9 Jul 2009
by Tom Igoe
modified 22 Nov 2010
by Tom Igoe
modified 7 Nov 2016
by Arturo Guadalupi
This example code is in the public domain.
http://www.arduino.cc/en/Tutorial/LiquidCrystalAutoscroll
*/// include the library code:
#include<LiquidCrystal.h>// initialize the library by associating any needed LCD interface pin
// with the arduino pin number it is connected to
constintrs=12,en=11,d4=5,d5=4,d6=3,d7=2;LiquidCrystallcd(rs,en,d4,d5,d6,d7);voidsetup(){// set up the LCD's number of columns and rows:
lcd.begin(16,2);}voidloop(){// set the cursor to (0,0):
lcd.setCursor(0,0);// print from 0 to 9:
for(intthisChar=0;thisChar<10;thisChar++){lcd.print(thisChar);delay(500);}// set the cursor to (16,1):
lcd.setCursor(16,1);// set the display to automatically scroll:
lcd.autoscroll();// print from 0 to 9:
for(intthisChar=0;thisChar<10;thisChar++){lcd.print(thisChar);delay(500);}// turn off automatic scrolling
lcd.noAutoscroll();// clear screen for the next loop:
lcd.clear();}
/*
LiquidCrystal Library - Blink
Demonstrates the use a 16x2 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 "Hello World!" to the LCD and makes the
cursor block blink.
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 resistor:
* ends to +5V and ground
* wiper to LCD VO pin (pin 3)
Library originally added 18 Apr 2008
by David A. Mellis
library modified 5 Jul 2009
by Limor Fried (http://www.ladyada.net)
example added 9 Jul 2009
by Tom Igoe
modified 22 Nov 2010
by Tom Igoe
modified 7 Nov 2016
by Arturo Guadalupi
This example code is in the public domain.
http://www.arduino.cc/en/Tutorial/LiquidCrystalBlink
*/// include the library code:
#include<LiquidCrystal.h>// initialize the library by associating any needed LCD interface pin
// with the arduino pin number it is connected to
constintrs=12,en=11,d4=5,d5=4,d6=3,d7=2;LiquidCrystallcd(rs,en,d4,d5,d6,d7);voidsetup(){// set up the LCD's number of columns and rows:
lcd.begin(16,2);// Print a message to the LCD.
lcd.print("hello, world!");}voidloop(){// Turn off the blinking cursor:
lcd.noBlink();delay(3000);// Turn on the blinking cursor:
lcd.blink();delay(3000);}
/*
LiquidCrystal Library - Cursor
Demonstrates the use a 16x2 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 "Hello World!" to the LCD and
uses the cursor() and noCursor() methods to turn
on and off the cursor.
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 resistor:
* ends to +5V and ground
* wiper to LCD VO pin (pin 3)
Library originally added 18 Apr 2008
by David A. Mellis
library modified 5 Jul 2009
by Limor Fried (http://www.ladyada.net)
example added 9 Jul 2009
by Tom Igoe
modified 22 Nov 2010
by Tom Igoe
modified 7 Nov 2016
by Arturo Guadalupi
This example code is in the public domain.
http://www.arduino.cc/en/Tutorial/LiquidCrystalCursor
*/// include the library code:
#include<LiquidCrystal.h>// initialize the library by associating any needed LCD interface pin
// with the arduino pin number it is connected to
constintrs=12,en=11,d4=5,d5=4,d6=3,d7=2;LiquidCrystallcd(rs,en,d4,d5,d6,d7);voidsetup(){// set up the LCD's number of columns and rows:
lcd.begin(16,2);// Print a message to the LCD.
lcd.print("hello, world!");}voidloop(){// Turn off the cursor:
lcd.noCursor();delay(500);// Turn on the cursor:
lcd.cursor();delay(500);}
/*
LiquidCrystal Library - display() and noDisplay()
Demonstrates the use a 16x2 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 "Hello World!" to the LCD and uses the
display() and noDisplay() functions to turn on and off
the display.
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 resistor:
* ends to +5V and ground
* wiper to LCD VO pin (pin 3)
Library originally added 18 Apr 2008
by David A. Mellis
library modified 5 Jul 2009
by Limor Fried (http://www.ladyada.net)
example added 9 Jul 2009
by Tom Igoe
modified 22 Nov 2010
by Tom Igoe
modified 7 Nov 2016
by Arturo Guadalupi
This example code is in the public domain.
http://www.arduino.cc/en/Tutorial/LiquidCrystalDisplay
*/// include the library code:
#include<LiquidCrystal.h>// initialize the library by associating any needed LCD interface pin
// with the arduino pin number it is connected to
constintrs=12,en=11,d4=5,d5=4,d6=3,d7=2;LiquidCrystallcd(rs,en,d4,d5,d6,d7);voidsetup(){// set up the LCD's number of columns and rows:
lcd.begin(16,2);// Print a message to the LCD.
lcd.print("hello, world!");}voidloop(){// Turn off the display:
lcd.noDisplay();delay(500);// Turn on the display:
lcd.display();delay(500);}
/*
LiquidCrystal Library - scrollDisplayLeft() and scrollDisplayRight()
Demonstrates the use a 16x2 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 "Hello World!" to the LCD and uses the
scrollDisplayLeft() and scrollDisplayRight() methods to scroll
the text.
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 resistor:
* ends to +5V and ground
* wiper to LCD VO pin (pin 3)
Library originally added 18 Apr 2008
by David A. Mellis
library modified 5 Jul 2009
by Limor Fried (http://www.ladyada.net)
example added 9 Jul 2009
by Tom Igoe
modified 22 Nov 2010
by Tom Igoe
modified 7 Nov 2016
by Arturo Guadalupi
This example code is in the public domain.
http://www.arduino.cc/en/Tutorial/LiquidCrystalScroll
*/// include the library code:
#include<LiquidCrystal.h>// initialize the library by associating any needed LCD interface pin
// with the arduino pin number it is connected to
constintrs=12,en=11,d4=5,d5=4,d6=3,d7=2;LiquidCrystallcd(rs,en,d4,d5,d6,d7);voidsetup(){// set up the LCD's number of columns and rows:
lcd.begin(16,2);// Print a message to the LCD.
lcd.print("hello, world!");delay(1000);}voidloop(){// scroll 13 positions (string length) to the left
// to move it offscreen left:
for(intpositionCounter=0;positionCounter<13;positionCounter++){// scroll one position left:
lcd.scrollDisplayLeft();// wait a bit:
delay(150);}// scroll 29 positions (string length + display length) to the right
// to move it offscreen right:
for(intpositionCounter=0;positionCounter<29;positionCounter++){// scroll one position right:
lcd.scrollDisplayRight();// wait a bit:
delay(150);}// scroll 16 positions (display length + string length) to the left
// to move it back to center:
for(intpositionCounter=0;positionCounter<16;positionCounter++){// scroll one position left:
lcd.scrollDisplayLeft();// wait a bit:
delay(150);}// delay at the end of the full loop:
delay(1000);}
/*
LiquidCrystal Library - Serial Input
Demonstrates the use a 16x2 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 displays text sent over the serial port
(e.g. from the Serial Monitor) on an attached 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 resistor:
* ends to +5V and ground
* wiper to LCD VO pin (pin 3)
Library originally added 18 Apr 2008
by David A. Mellis
library modified 5 Jul 2009
by Limor Fried (http://www.ladyada.net)
example added 9 Jul 2009
by Tom Igoe
modified 22 Nov 2010
by Tom Igoe
modified 7 Nov 2016
by Arturo Guadalupi
This example code is in the public domain.
http://www.arduino.cc/en/Tutorial/LiquidCrystalSerialDisplay
*/// include the library code:
#include<LiquidCrystal.h>// initialize the library by associating any needed LCD interface pin
// with the arduino pin number it is connected to
constintrs=12,en=11,d4=5,d5=4,d6=3,d7=2;LiquidCrystallcd(rs,en,d4,d5,d6,d7);voidsetup(){// set up the LCD's number of columns and rows:
lcd.begin(16,2);// initialize the serial communications:
Serial.begin(9600);}voidloop(){// when characters arrive over the serial port...
if(Serial.available()){// wait a bit for the entire message to arrive
delay(100);// clear the screen
lcd.clear();// read all the available characters
while(Serial.available()>0){// display each character to the LCD
lcd.write(Serial.read());}}}
/*
LiquidCrystal Library - setCursor
Demonstrates the use a 16x2 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 to all the positions of the LCD using the
setCursor() method:
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 resistor:
* ends to +5V and ground
* wiper to LCD VO pin (pin 3)
Library originally added 18 Apr 2008
by David A. Mellis
library modified 5 Jul 2009
by Limor Fried (http://www.ladyada.net)
example added 9 Jul 2009
by Tom Igoe
modified 22 Nov 2010
by Tom Igoe
modified 7 Nov 2016
by Arturo Guadalupi
This example code is in the public domain.
http://www.arduino.cc/en/Tutorial/LiquidCrystalSetCursor
*/// include the library code:
#include<LiquidCrystal.h>// initialize the library by associating any needed LCD interface pin
// with the arduino pin number it is connected to
constintrs=12,en=11,d4=5,d5=4,d6=3,d7=2;LiquidCrystallcd(rs,en,d4,d5,d6,d7);// these constants won't change. But you can change the size of
// your LCD using them:
constintnumRows=2;constintnumCols=16;voidsetup(){// set up the LCD's number of columns and rows:
lcd.begin(numCols,numRows);}voidloop(){// loop from ASCII 'a' to ASCII 'z':
for(intthisLetter='a';thisLetter<='z';thisLetter++){// loop over the columns:
for(intthisRow=0;thisRow<numRows;thisRow++){// loop over the rows:
for(intthisCol=0;thisCol<numCols;thisCol++){// set the cursor position:
lcd.setCursor(thisCol,thisRow);// print the letter:
lcd.write(thisLetter);delay(200);}}}}
/*
LiquidCrystal Library - TextDirection
Demonstrates the use a 16x2 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 demonstrates how to use leftToRight() and rightToLeft()
to move the cursor.
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 resistor:
* ends to +5V and ground
* wiper to LCD VO pin (pin 3)
Library originally added 18 Apr 2008
by David A. Mellis
library modified 5 Jul 2009
by Limor Fried (http://www.ladyada.net)
example added 9 Jul 2009
by Tom Igoe
modified 22 Nov 2010
by Tom Igoe
modified 7 Nov 2016
by Arturo Guadalupi
This example code is in the public domain.
http://www.arduino.cc/en/Tutorial/LiquidCrystalTextDirection
*/// include the library code:
#include<LiquidCrystal.h>// initialize the library by associating any needed LCD interface pin
// with the arduino pin number it is connected to
constintrs=12,en=11,d4=5,d5=4,d6=3,d7=2;LiquidCrystallcd(rs,en,d4,d5,d6,d7);intthisChar='a';voidsetup(){// set up the LCD's number of columns and rows:
lcd.begin(16,2);// turn on the cursor:
lcd.cursor();}voidloop(){// reverse directions at 'm':
if(thisChar=='m'){// go right for the next letter
lcd.rightToLeft();}// reverse again at 's':
if(thisChar=='s'){// go left for the next letter
lcd.leftToRight();}// reset at 'z':
if(thisChar>'z'){// go to (0,0):
lcd.home();// start again at 0
thisChar='a';}// print the character
lcd.write(thisChar);// wait a second:
delay(1000);// increment the letter:
thisChar++;}
/*
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
modified 7 Nov 2016
by Arturo Guadalupi
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/LiquidCrystalCustomCharacter
Also useful:
http://icontexto.com/charactercreator/
*/// include the library code:
#include<LiquidCrystal.h>// initialize the library by associating any needed LCD interface pin
// with the arduino pin number it is connected to
constintrs=12,en=11,d4=5,d5=4,d6=3,d7=2;LiquidCrystallcd(rs,en,d4,d5,d6,d7);// make some custom characters:
byteheart[8]={0b00000,0b01010,0b11111,0b11111,0b11111,0b01110,0b00100,0b00000};bytesmiley[8]={0b00000,0b00000,0b01010,0b00000,0b00000,0b10001,0b01110,0b00000};bytefrownie[8]={0b00000,0b00000,0b01010,0b00000,0b00000,0b00000,0b01110,0b10001};bytearmsDown[8]={0b00100,0b01010,0b00100,0b00100,0b01110,0b10101,0b00100,0b01010};bytearmsUp[8]={0b00100,0b01010,0b00100,0b10101,0b01110,0b00100,0b00100,0b01010};voidsetup(){// initialize LCD and set up the number of columns and rows:
lcd.begin(16,2);// create a new character
lcd.createChar(0,heart);// create a new character
lcd.createChar(1,smiley);// create a new character
lcd.createChar(2,frownie);// create a new character
lcd.createChar(3,armsDown);// create a new character
lcd.createChar(4,armsUp);// set the cursor to the top left
lcd.setCursor(0,0);// Print a message to the lcd.
lcd.print("I ");lcd.write(byte(0));// when calling lcd.write() '0' must be cast as a byte
lcd.print(" Arduino! ");lcd.write((byte)1);}voidloop(){// read the potentiometer on A0:
intsensorReading=analogRead(A0);// map the result to 200 - 1000:
intdelayTime=map(sensorReading,0,1023,200,1000);// set the cursor to the bottom row, 5th position:
lcd.setCursor(4,1);// draw the little man, arms down:
lcd.write(3);delay(delayTime);lcd.setCursor(4,1);// draw him arms up:
lcd.write(4);delay(delayTime);}