Introduction: Lcd Project With Led on or OFF With Arduino

About: pursuing Bachelors in Electronics and Communication at Chandigarh University

In this project , we will add LCD with controlling led with push button project. To learn how to connect LCD with Arduino click on this link.

Components Required

  1. Arduino - https://amzn.to/32jAMUA
  2. 16 X 2 LCD Display - https://amzn.to/35VXFQl
  3. Potentiometer 10Kohms - https://amzn.to/2ZuPNRN
  4. 220 ohms resistor - https://amzn.to/2ZuPNRN
  5. Jumper wires - https://amzn.to/3iqdBxM
  6. push button - https://amzn.to/3kFPn33
  7. led - https://amzn.to/3iUmIad

Step 1: Circuit Schematic

Step 2: Arduino Code

// include the library code:

#include <LiquidCrystal.h>

// initialize the library with the numbers of the interface pins

LiquidCrystal lcd(12, 11, 5, 4, 3, 2);

int data =0;

void setup() {

pinMode(13, OUTPUT);

pinMode(8, OUTPUT);

pinMode(A0, INPUT);

digitalWrite(8,LOW);

// set up the LCD's number of columns and rows:

lcd.begin(16, 2);

// set the cursor to column 0, line 0

lcd.setCursor(0, 0);

// Print a message to the LCD.

lcd.print("Home Automation");

lcd.setCursor(0, 1);

// print the number of seconds since reset:

lcd.print("Tubelight: ");

}

void loop() {

data= digitalRead(A0);

if(data == HIGH) {

digitalWrite(13,HIGH);

lcd.setCursor(13,1);

// comment this command to see the difference without it

lcd.print(" ");

lcd.setCursor(11,1);

lcd.print("ON");

}

else{

digitalWrite(13,LOW);

lcd.setCursor(11,1);

lcd.print("OFF");

} }