Controlling LCD from Push Button Using Arduino

Parts Required :

Resistors

1 K Ohm (1 No)

1Kres

 

220 Ohm resistor – 1no

220r

Potentiometer 10K

pot10k

Arduino Uno Board

uno

 

 

LC Display

LCD-Display-Tutorial

Push Button Switch

pushbutton_legs_final

 

Circuit Diagram

circuit

Arduino Code:

// By Haneefputtur.com
 // 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 Anode Pin to Analog Pin A4
// Push Button to digital Pin 8
#include <LiquidCrystal.h>
#define LCD_LIGHT_PIN A4
const int buttonPin = 8; 
LiquidCrystal lcd(12, 11, 5, 4, 3, 2); 
int buttonState = 0;

void setup() { 
 // Setup the number of columns and rows that are available on the LCD. 
 lcd.begin(16, 2);
 lcd.noDisplay();

 // Set the button pin as an input.
 pinMode(buttonPin, INPUT);

 // Set the LCD display backlight pin as an output.
 pinMode(LCD_LIGHT_PIN, OUTPUT);

 // Turn off the LCD backlight.
 digitalWrite(LCD_LIGHT_PIN, LOW);
}

void loop() { 
 buttonState = digitalRead(buttonPin);
 if (buttonState == HIGH)
 {
 // Print some text to the LCD.
 lcd.clear();
 lcd.setCursor(0, 0);
 lcd.print("Haneef Puttur.com");

 // Turn the backlight on.
 digitalWrite(LCD_LIGHT_PIN, HIGH);

 // Display the text on the LCD.
 lcd.display();

 // Wait for 10 seconds and write next line.
 delay(10000);
 lcd.clear();
 lcd.setCursor(0, 0);
 lcd.print("Welcome to Arduino");
 // Wait for 10 seconds and write next line.
 delay(1000);
 lcd.clear();
 lcd.setCursor(0, 0);
 lcd.print("Add Your Name Here");
 // Wait for 10 seconds and turn off.
 delay(10000);
 lcd.noDisplay();
 digitalWrite(LCD_LIGHT_PIN, LOW);
 }
}

This will display lines of code and go to sleep mode.

When the push button is pressed , display will start again.