EngineersGarage

  • Engineers Garage Main Site
  • Visit our active EE Forums
    • EDABoard.com
    • Electro-Tech-Online
  • Projects & Tutorials
    • Circuits
    • Electronic Projects
    • Tutorials
    • Components
  • Digi-Key Store
    • Cables, Wires
    • Connectors, Interconnect
    • Discrete
    • Electromechanical
    • Embedded Computers
    • Enclosures, Hardware, Office
    • Integrated Circuits (ICs)
    • Isolators
    • LED/Optoelectronics
    • Passive
    • Power, Circuit Protection
    • Programmers
    • RF, Wireless
    • Semiconductors
    • Sensors, Transducers
    • Test Products
    • Tools
  • Advertise
You are here: Home / Replies / How to get keypad inputs to initialise the time in the LCD clock

How to get keypad inputs to initialise the time in the LCD clock

|

Microcontroller › Arduino › how to get keypad inputs to initialise the time in the clock › How to get keypad inputs to initialise the time in the LCD clock

April 23, 2016 at 6:08 am #13888
sunil
Participant
The following code written for LCD based hourly Alarm Digital clock. 
Here, the current time is initialised in the program itself. But i want to know how can we initialise the time from keypad?
Can anyone please help??
Thanks in advance…
 
 
 
#include <Keypad.h> 
#include <LiquidCrystal.h>
// initialize the library with the numbers of the interface pins
LiquidCrystal lcd(8, 9, 10, 11, 12, 13);//RS,EN,D4,D5,D6,D7
const byte ROWS = 4; // Four rows
const byte COLS = 4; // Three columns
// Define the Keymap
char keys[ROWS][COLS] = {
  {'1','2','3','A'},
  {'4','5','6','B'},
  {'7','8','9','C'},
  {'*','0','#','D'}
};
// Connect keypad ROW0, ROW1, ROW2 and ROW3 to these Arduino pins.
byte rowPins[ROWS] = { 0, 1, 2, 3 };
// Connect keypad COL0, COL1 and COL2 to these Arduino pins.
byte colPins[COLS] = { 4, 5, 6, 7 };
//  Create the Keypad
Keypad kpd = Keypad( makeKeymap(keys), rowPins, colPins, ROWS, COLS );
int k,hi=22,mi=24,si=45,h,m,s,s1,s2,m1,m2,h1,h2;
int buzz = A1;
void setup()
{
  for(int k=8;k<14;k++)
  {
    pinMode(k,OUTPUT);//pins 8-14 are enabled as output
  }
  lcd.begin(16, 2);//initializing LCD
  pinMode(buzz, OUTPUT);
}
void loop() 
{
  for(h=hi; h<24; h++,m=0) //initialise the 'h' value to current hour
  {
   for(m=mi; m<60; m++) //initilaise the 'm' value to current minute
   {
     for(s=si; s<60; s++)
     {
       lcd.clear();
       lcd.print("TIME # ");
       lcd.setCursor(0,1);
       h1=h/10;
       h2=h%10;
       m1=m/10;
       m2=m%10;
       s1=s/10;
       s2=s%10;
       lcd.setCursor(7,0);
       lcd.print(h1);
       lcd.setCursor(8,0);
       lcd.print(h2);
       lcd.setCursor(9,0);
       lcd.print(":");
       lcd.setCursor(10,0);
       lcd.print(m1);
       lcd.setCursor(11,0);
       lcd.print(m2);
       lcd.setCursor(12,0);
       lcd.print(":");
       lcd.setCursor(13,0);
       lcd.print(s1);
       lcd.setCursor(14,0);
       lcd.print(s2);
       delay(1000);
       if(m==0 && s<15)
        digitalWrite(buzz, HIGH);
       else
        digitalWrite(buzz, LOW);
      si=0;        
     }
     mi=0;
   }
   hi=0;
 }
}

RSS Recent Posts

  • Relay question May 19, 2026
  • Phone Charger 5v to 12v May 19, 2026
  • reviving old swordfish program but? May 18, 2026
  • Assistance locating a 'trail' camera gadget, please ? May 18, 2026
  • Projector focus circuit May 18, 2026

Stay Up To Date

Newsletter Signup
EngineersGarage

Copyright © 2026 WTWH Media LLC. All Rights Reserved. The material on this site may not be reproduced, distributed, transmitted, cached or otherwise used, except with the prior written permission of WTWH Media
Privacy Policy | Advertising | About Us

Search Engineers Garage

  • Engineers Garage Main Site
  • Visit our active EE Forums
    • EDABoard.com
    • Electro-Tech-Online
  • Projects & Tutorials
    • Circuits
    • Electronic Projects
    • Tutorials
    • Components
  • Digi-Key Store
    • Cables, Wires
    • Connectors, Interconnect
    • Discrete
    • Electromechanical
    • Embedded Computers
    • Enclosures, Hardware, Office
    • Integrated Circuits (ICs)
    • Isolators
    • LED/Optoelectronics
    • Passive
    • Power, Circuit Protection
    • Programmers
    • RF, Wireless
    • Semiconductors
    • Sensors, Transducers
    • Test Products
    • Tools
  • Advertise