Tinkercad_LCD
LCD interface to Arduino
// simple LCD program interface to Arduino Uno
#include <Adafruit_LiquidCrystal.h>
Adafruit_LiquidCrystal lcd_1(0);
void setup()
{
lcd_1.begin(16, 2);
}
void loop()
{
lcd_1.begin(16, 2);
lcd_1.print("hello world");
delay(1000);
}
Types of LCD:
16x2:
connections in detail:
* 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
* 5V (pin of Arduino) to POT 10K Terminal(1); then Terminal(2) of POT to GND (of Arduino)
* wiper to LCD VO pin (pin 3)
16x2 I2C: easy way of connection
Vcc of LCD = 5V of Arduino
GND of LCD = GND of Arduino
SDA of LCD = SDA of Arduino
SCL of LCD = SCL of Arduino
What is 16x2 LCD?
16= columns
2= rows
So it is columns vs rows (not rows vs columns)
16= columns
2= rows
So it is columns vs rows (not rows vs columns)
position of A is (0,0)
position of P is (15,0)
position of Q is (0,1)
position of 5 is (15,1)
i.e., (column, row)
position of P is (15,0)
position of Q is (0,1)
position of 5 is (15,1)
i.e., (column, row)
// write a program to print U only at its position
sample output:
#include <Adafruit_LiquidCrystal.h>
Adafruit_LiquidCrystal lcd_1(0);
void setup()
{
lcd_1.begin(16, 2);
}
void loop()
{
lcd_1.setCursor(4, 1);
lcd_1.print("U");
}
LCD 16x2 I2C model:
#include <Adafruit_LiquidCrystal.h>
int seconds = 0;
Adafruit_LiquidCrystal lcd_1(0);
void setup()
{
lcd_1.begin(16, 2);
lcd_1.print("hello world");
delay(1000);
}
void loop()
{
// lcd_1.setCursor(0, 0);
// lcd_1.print("ABCDEFGHIJKLMNOP");
// lcd_1.setCursor(0,1);
// lcd_1.print("QRSTUVWXYZ0123456789");
// delay(1000);
lcd_1.setCursor(0,0);
lcd_1.print("Pragati Engg College");
lcd_1.setCursor(0,8);
lcd_1.print("IOT Lab");
for (int positionCounter = 0; positionCounter < 13; positionCounter++) {
// scroll one position left:
lcd_1.scrollDisplayLeft();
// wait a bit:
delay(150);
}
}
connections in detail:
* 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
* 5V (pin of Arduino) to POT 10K Terminal(1); then Terminal(2) of POT to GND (of Arduino)
* wiper to LCD VO pin (pin 3)
#include <LiquidCrystal.h>
const int rs = 12, en = 11, d4 = 5, d5 = 4, d6 = 3, d7 = 2;
LiquidCrystal lcd(rs, en, d4, d5, d6, d7);
void setup() {
// 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);
}
void loop() {
// scroll 13 positions (string length) to the left
// to move it offscreen left:
for (int positionCounter = 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 (int positionCounter = 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 (int positionCounter = 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);
}