Microcontroller › Arduino › how to get keypad inputs to initialise the time in the clock
- This topic has 1 reply, 1 voice, and was last updated 8 years, 4 months ago by sunil.
Viewing 2 posts - 1 through 2 (of 2 total)
-
AuthorPosts
-
April 22, 2016 at 5:12 pm #4427sunilParticipantHi,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.#include <Keypad.h>#include <LiquidCrystal.h>// initialize the library with the numbers of the interface pinsLiquidCrystal lcd(8, 9, 10, 11, 12, 13);//RS,EN,D4,D5,D6,D7const byte ROWS = 4; // Four rowsconst byte COLS = 4; // Three columns// Define the Keymapchar 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 KeypadKeypad 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 LCDpinMode(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);elsedigitalWrite(buzz, LOW);si=0;}mi=0;}hi=0;}}April 23, 2016 at 6:08 am #13888sunilParticipantThe 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 pinsLiquidCrystal lcd(8, 9, 10, 11, 12, 13);//RS,EN,D4,D5,D6,D7const byte ROWS = 4; // Four rowsconst byte COLS = 4; // Three columns// Define the Keymapchar 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 KeypadKeypad 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 LCDpinMode(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);elsedigitalWrite(buzz, LOW);si=0;}mi=0;}hi=0;}} -
AuthorPosts
Viewing 2 posts - 1 through 2 (of 2 total)
- You must be logged in to reply to this topic.