Set the time using four switch and display the clock on LCD using arduino ** SW1 : when press, increment 1 digit ** SW2 : when press, decrement 1 digit ** SW3 : when press, display set time and start the clock ** SW4 : when press, reset the clock

Here i am using online IDE Tinkercad . If you don't know what is tinkercad then refer my blog HERE or else you can use offline IDE also.

Code :-

#include <LiquidCrystal.h>

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

void setup() {

  lcd.begin(16, 2);

  pinMode(6, INPUT);

  pinMode(7, INPUT);

  pinMode(8, INPUT);

  pinMode(9, INPUT);

  Serial.begin(9600);

}

int i =0;

void loop() {

if(digitalRead(6)== HIGH){

        lcd.setCursor(0,0); 

    i++;

            lcd.print(i);

  }

 if(digitalRead(7)== HIGH){

 lcd.setCursor(0,0);        

     if(i>0){

             i--;

     }    

            lcd.print(i);

  }

  if(digitalRead(8)== HIGH){

     lcd.setCursor(0,0);    

            lcd.print(i);

  }

  if(digitalRead(9)== HIGH){

  lcd.clear();

  }

}

Output :-



Comments

Popular Posts

What is Tinkercad ? How to use Tinkercad ?

Connect switch to Arduino. If switch is on than print ”ON” else print “OFF” on serial monitor.

Develop an interfacing circuit and a sketch to increment count on 7-Segment based on switch press. Count goes from 00 to 99.