Monday 5 September 2016

Interfacing of Lcd with Arduino

Interfacing of Lcd with Arduino:


Display "welcome to all" on the lcd.

#include<LiquidCrystal.h>
LiquidCrystal lcd(2,3,4,5,6,7);

void setup()
{
  lcd.begin(16,2);
  lcd.print("welcome to all");
}
void loop()
{
  lcd.setCursor(5,2);

}

Simulation:



Lcd with Switch:


#include<LiquidCrystal.h>
int sw1=1;
int sw2=8;
LiquidCrystal lcd(2,3,4,5,6,7);
int led1=9;
int led2=10;

void setup()
{
  pinMode(sw1,INPUT);
  pinMode(sw2,INPUT);
  lcd.begin(16,2);
  pinMode(led1,OUTPUT);
  pinMode(led2,OUTPUT);
  digitalWrite(sw1, HIGH);
  digitalWrite(sw2,HIGH);
}

void loop()
  if(digitalRead(sw1)==0)
  {
   lcd.clear();
   lcd.print("switch 1 is on");
   digitalWrite(led1,HIGH);
   delay(1000);
   digitalWrite(led1,LOW);
  // delay(1000);
  }
  
  else
  {
    lcd.clear();
   lcd.print("switch 1 is off");
   //digitalWrite(led1,HIGH);
   //delay(1000);
  // digitalWrite(led1,LOW);
  // delay(1000);
  }
 
  if(digitalRead(sw2)==0)
  {
   lcd.setCursor(0,1);
   lcd.print("switch 2 is on");
   digitalWrite(led2,HIGH);
   delay(1000);
   digitalWrite(led2,LOW);
  // delay(1000);
  } 


  else 
  {
    lcd.setCursor(0,1);
    lcd.print("switch 2 is off");
  //  delay(1000);
  }
  
  delay(1000);



Simulation:




 










0 comments:

Post a Comment

if you have any doubt please let me know