This program allows the user to set the time from the serial terminal on power on. Thereafter the clock will run as the real time clock. The user is able to set the alarm time using the joystick. Down button is used to increase the time and center button is used to set. The alarm will sound when the alarm time and actual time are equal. Right button of joystick is used to stop the alarm. The alarm will stop automatically after specified duration (hard coded) if the stop button is not pressed.

Dependencies:   C12832_lcd DebounceInterrupts mbed-rtos mbed USBDevice

GOAL:

To implement a simple alarm clock using MBED Application borad LPC1768.

USER CONTROLS

  • USB interface to set the clock initially. This is required only when the board is powered ON.
  • Joystick down button to increase the hrs/mins.
  • Joystick center button to toggle between hrs and min.
  • Joystick right button to stop the alarm.
  • LCD to display the actual time and the alarm time.

DETAILS

  • Thread compare_time is used to compare the actual time and the alarm time set by the user.
  • Thread update_lcd is used to display the actual time and the alarm time set by the user on the LCD.
  • Main thread is used to initiate threads to update LCD and thread to compare timings.
  • A ticker is used to update the actual time every second.

TESTING

  • User Level Testing
Test ItemDescriptionStatus
USB ConnectionVerify if the device is recognized as USB Serial Device even when connected to a USB hubPASS
Verify the set time is displayed on the LCDPASS
Set time updateVerify the Set time is updated every second.PASS
Setting the Alarm timeVerify the alarm time is getting updated on the LCD as the time increase button is pressedPASS
Sounding the AlarmVerify the alarm and the alarm LED (LED2)are turned ON when the actual time and the set time are equalPASS
Stopping the AlarmWhen the alarm is ON and the user presses the right button of the joystick the alarm should turn OFF and the Alarm LED LED2 should be OFF.PASS
If the User does not press the alarm stop button within a minute the alarm should turn OFFPASS
  • Product Level Testing
Test ItemDescriptionStatus
ProgrammingVerify mbed is detected as Mass Storage Device and is programmed by the hostPASS
USBVerify the power consumed by the USB device. Current drawn is 160mA. Power is 800mW.Satisfies the USB specification
Normal Working (After the time is set)After setting the time remove the USB.(Be sure to connect the external supply before removing the USB)The clock works satisfactorily on the external power supply.
Key DebounceVerify that there is no debounce on any of the joystick keys.PASS

Import programRTOS_Alarm_Clock

This program allows the user to set the time from the serial terminal on power on. Thereafter the clock will run as the real time clock. The user is able to set the alarm time using the joystick. Down button is used to increase the time and center button is used to set. The alarm will sound when the alarm time and actual time are equal. Right button of joystick is used to stop the alarm. The alarm will stop automatically after specified duration (hard coded) if the stop button is not pressed.

main.cpp

/*****************************************************************************/
/*      Main program for the implementation of RTOS_ALARM Clock              */
/*Function: To sound an alarm when the actual time is equal to alarm time    */
/*Features: USB access to set the time                                       */
/*          User can set the time with the joystick                          */
/*          Audio Visual alarm available                                     */
/*          Alarm turns OFF automaticaaly after 1 min if not turned OFF      */
/*Author:   Bhakti Kulkarni                                                  */
/*Date:     03/25/2014                                                       */
/*****************************************************************************/

#include "mbed.h"
#include "C12832_lcd.h"
#include "DebouncedIn.h"
#include "DebouncedInterrupt.h"
#include "rtos.h"
#include "USBSerial.h"

#define INTERRUPT
#define HR 1
#define MIN 0
#define DURATION 1
#define MAX_HRS 24
#define MAX_MINS 60
#define MAX_SECS 60

C12832_LCD lcd;
USBSerial serial;

DebouncedInterrupt increase(p12);                     //Switch to increase time
DebouncedInterrupt select(p14);         //Switch to toggle between hrs and mins
Mutex M_lcd;                            //Mutex for LCD
DebouncedIn stop_alarm(p16);            //Switch to stop the alarm
Ticker update_time;                     //Ticker to update actual time
DigitalOut wake_up(LED2);               //Visual alarm LED
PwmOut speaker(p26);                    //Speaker for audible alarm

/*Global variables for mins and hrs*/
int hrs;
int mins;
int hrs_set = MAX_HRS;
int mins_set = MAX_MINS;
int sec_set = 0;
bool selection= HR;            //Signal to indicate the hrs/mins to be changed

/*****************************************************************************/
/*                     ISR for increasing the time                           */
/*Function: This routine checks the value of selection signal.               */
/*          If selection value - HR it updates hrs and if selection = MIN    */
/*          it updates the minute value. It also checks for the maximum      */
/*          value of hrs and mins and reset appropriate variable             */
/*****************************************************************************/
void increase_time()
{
    if (selection == HR)
    { 
      if (hrs < MAX_HRS)
         hrs ++;
      else
         hrs = 0;
    }
    else
    {
        if (mins < MAX_MINS)
           mins ++;
         else{
           mins = 0;
           if (hrs < MAX_HRS)
            hrs++;
           else
             hrs = 0;
        }
     }
}
/*****************************************************************************/

/*****************************************************************************/
/*                          ISR to update selection                          */
/*Function: Allows the user to toggle between the hours and minutes          */
/*****************************************************************************/
void select_time()
{
    selection = !selection;
}
/*****************************************************************************/

/*****************************************************************************/
/*                        Thread to update LCD                               */
/*Function: This thread updates the LCD with the actual and the alarm time   */
/*****************************************************************************/
void update_lcd(void const *args)
{
    M_lcd.lock();                                       //Mutex to lock the LCD
    lcd.cls();
    lcd.locate(0,20);
    while(1) {
        lcd.cls();
        lcd.locate(0,0);
        lcd.printf("Actual-hh:mm:sec %02d:%02d:%02d",hrs_set,mins_set,sec_set);
        lcd.locate(0,10);
        lcd.printf("Alarm-hh:mm:sec %02d:%02d:%02d",hrs,mins,0);
        M_lcd.unlock();  
        Thread::wait(25);
    }
}
/*****************************************************************************/

/*****************************************************************************/
/*                   Ticker function to update the actual time               */
/*This function is called every second. It increments no. of seconds         */
/*Also checks for max secs, mins and hours and accordingly adjusts other     */
/*variables.                                                                 */
/*****************************************************************************/
void time_update()
{
    sec_set++;
    if (sec_set == MAX_MINS)
    {
        mins_set++;
        sec_set = 0;
    }
    if (mins_set == MAX_MINS)
    {
        hrs_set++;
        mins_set = 0;
    }
    if (hrs_set == MAX_HRS)
    {
        hrs_set = 0;
        mins_set = 0;
        sec_set = 0;
    }
}
/*****************************************************************************/

/*****************************************************************************/
/*                        Function to sound the alarm                        */
/*This function is called when the alarm time = actual time                  */
/*It sounds the alarm till alarm_stop button is pressed | 1 min is ellapsed  */
/*The variable frequency and beat rate of the PWM decide the tone of alarm   */
/*****************************************************************************/
void alarm_on()
{
    float frequency[]={659,554,659,554,440,494,554,587,494,659,554,440};
    float beat[]={1,1,1,1,1,0.5,0.5,1,1,1,1,2}; //beat array
    while (!stop_alarm && !(hrs_set == hrs && mins_set == mins+DURATION)) {
        wake_up = 1;
        for (int i=0;i<=11;i++) {
            speaker.period(1/(2*frequency[i])); // set PWM period
            speaker=0.5; // set duty cycle
            wait(0.4*beat[i]); // hold for beat period
        }
    }
    wake_up =0;                                       //Turn OFF visual alarm
    speaker = 0.0;                                     //Turn OFF audio alarm
}
/*****************************************************************************/

/*****************************************************************************/
/*                    Thread for time Comparison                             */
/*This thread comapres the actual and the alarm time and calls the alarm     */
/*function when both the timings are equal. It also reset the alarm time     */
/*after the alarm is turned OFF(either by user or after a minute is ellapsed)*/
/*****************************************************************************/
void sound_alarm(void const *args)
{
    while (true){
    if ((hrs == hrs_set && mins_set == mins && sec_set == 0) )
    {
        alarm_on();
        hrs = 0;
        mins = 0;
    }
    Thread::wait(50);
    }
}
/*****************************************************************************/

/*****************************************************************************/
/*                               Main Thread                                 */
/*Initializes all the threads and the USB inerface.                          */
/*This thread makes a blocking call to set the time. In this application     */
/*blocking call is used since the actual time is necessary parameter for the */
/*alarm clock. Without the time alarm clock has no function to do.           */
/*****************************************************************************/
int main() {
    char ch;
    increase.attach(&increase_time);
    select.attach(&select_time);
    Thread compare_time (sound_alarm,NULL,osPriorityAboveNormal);
    Thread lcd_display(update_lcd,NULL,  osPriorityAboveNormal);
    serial.printf("\r\n");
    serial.scanf("%c",&ch);
    serial.printf("Set the hours\r\n");
    do{
        serial.scanf("%d",&hrs_set);
        if (hrs_set > MAX_HRS)
            serial.printf("Enter Valid hours\r\n");
    }while (hrs_set > MAX_HRS);              //error checking for hours entered
    serial.printf("Set mins\r\n");
    do
    {
        serial.scanf("%d",&mins_set);
        if (mins_set > MAX_MINS)
            serial.printf("Enter Valid minutes\r\n");
    }while (mins_set > MAX_MINS);          //error checking for minutes entered
    update_time.attach(&time_update,1);
    while(1)
    {
        Thread::wait(1000);
    }
}

.

Committer:
bhakti08
Date:
Tue Mar 25 20:11:11 2014 +0000
Revision:
2:ef21b03bb9c2
Parent:
1:aa410246cf19
Final Version

Who changed what in which revision?

UserRevisionLine numberNew contents of line
bhakti08 2:ef21b03bb9c2 1 /*****************************************************************************/
bhakti08 2:ef21b03bb9c2 2 /* Main program for the implementation of RTOS_ALARM Clock */
bhakti08 2:ef21b03bb9c2 3 /*Function: To sound an alarm when the actual time is equal to alarm time */
bhakti08 2:ef21b03bb9c2 4 /*Features: USB access to set the time */
bhakti08 2:ef21b03bb9c2 5 /* User can set the time with the joystick */
bhakti08 2:ef21b03bb9c2 6 /* Audio Visual alarm available */
bhakti08 2:ef21b03bb9c2 7 /* Alarm turns OFF automaticaaly after 1 min if not turned OFF */
bhakti08 2:ef21b03bb9c2 8 /*Author: Bhakti Kulkarni */
bhakti08 2:ef21b03bb9c2 9 /*Date: 03/25/2014 */
bhakti08 2:ef21b03bb9c2 10 /*****************************************************************************/
bhakti08 2:ef21b03bb9c2 11
bhakti08 0:cdc96a6032be 12 #include "mbed.h"
bhakti08 0:cdc96a6032be 13 #include "C12832_lcd.h"
bhakti08 0:cdc96a6032be 14 #include "DebouncedIn.h"
bhakti08 0:cdc96a6032be 15 #include "DebouncedInterrupt.h"
bhakti08 0:cdc96a6032be 16 #include "rtos.h"
bhakti08 1:aa410246cf19 17 #include "USBSerial.h"
bhakti08 0:cdc96a6032be 18
bhakti08 0:cdc96a6032be 19 #define INTERRUPT
bhakti08 0:cdc96a6032be 20 #define HR 1
bhakti08 0:cdc96a6032be 21 #define MIN 0
bhakti08 0:cdc96a6032be 22 #define DURATION 1
bhakti08 0:cdc96a6032be 23 #define MAX_HRS 24
bhakti08 0:cdc96a6032be 24 #define MAX_MINS 60
bhakti08 0:cdc96a6032be 25 #define MAX_SECS 60
bhakti08 0:cdc96a6032be 26
bhakti08 0:cdc96a6032be 27 C12832_LCD lcd;
bhakti08 1:aa410246cf19 28 USBSerial serial;
bhakti08 0:cdc96a6032be 29
bhakti08 2:ef21b03bb9c2 30 DebouncedInterrupt increase(p12); //Switch to increase time
bhakti08 2:ef21b03bb9c2 31 DebouncedInterrupt select(p14); //Switch to toggle between hrs and mins
bhakti08 2:ef21b03bb9c2 32 Mutex M_lcd; //Mutex for LCD
bhakti08 2:ef21b03bb9c2 33 DebouncedIn stop_alarm(p16); //Switch to stop the alarm
bhakti08 2:ef21b03bb9c2 34 Ticker update_time; //Ticker to update actual time
bhakti08 2:ef21b03bb9c2 35 DigitalOut wake_up(LED2); //Visual alarm LED
bhakti08 2:ef21b03bb9c2 36 PwmOut speaker(p26); //Speaker for audible alarm
bhakti08 0:cdc96a6032be 37
bhakti08 2:ef21b03bb9c2 38 /*Global variables for mins and hrs*/
bhakti08 0:cdc96a6032be 39 int hrs;
bhakti08 0:cdc96a6032be 40 int mins;
bhakti08 0:cdc96a6032be 41 int hrs_set = MAX_HRS;
bhakti08 0:cdc96a6032be 42 int mins_set = MAX_MINS;
bhakti08 1:aa410246cf19 43 int sec_set = 0;
bhakti08 2:ef21b03bb9c2 44 bool selection= HR; //Signal to indicate the hrs/mins to be changed
bhakti08 0:cdc96a6032be 45
bhakti08 2:ef21b03bb9c2 46 /*****************************************************************************/
bhakti08 2:ef21b03bb9c2 47 /* ISR for increasing the time */
bhakti08 2:ef21b03bb9c2 48 /*Function: This routine checks the value of selection signal. */
bhakti08 2:ef21b03bb9c2 49 /* If selection value - HR it updates hrs and if selection = MIN */
bhakti08 2:ef21b03bb9c2 50 /* it updates the minute value. It also checks for the maximum */
bhakti08 2:ef21b03bb9c2 51 /* value of hrs and mins and reset appropriate variable */
bhakti08 2:ef21b03bb9c2 52 /*****************************************************************************/
bhakti08 0:cdc96a6032be 53 void increase_time()
bhakti08 0:cdc96a6032be 54 {
bhakti08 0:cdc96a6032be 55 if (selection == HR)
bhakti08 0:cdc96a6032be 56 {
bhakti08 0:cdc96a6032be 57 if (hrs < MAX_HRS)
bhakti08 0:cdc96a6032be 58 hrs ++;
bhakti08 0:cdc96a6032be 59 else
bhakti08 0:cdc96a6032be 60 hrs = 0;
bhakti08 0:cdc96a6032be 61 }
bhakti08 0:cdc96a6032be 62 else
bhakti08 0:cdc96a6032be 63 {
bhakti08 0:cdc96a6032be 64 if (mins < MAX_MINS)
bhakti08 0:cdc96a6032be 65 mins ++;
bhakti08 0:cdc96a6032be 66 else{
bhakti08 0:cdc96a6032be 67 mins = 0;
bhakti08 0:cdc96a6032be 68 if (hrs < MAX_HRS)
bhakti08 0:cdc96a6032be 69 hrs++;
bhakti08 0:cdc96a6032be 70 else
bhakti08 0:cdc96a6032be 71 hrs = 0;
bhakti08 0:cdc96a6032be 72 }
bhakti08 0:cdc96a6032be 73 }
bhakti08 0:cdc96a6032be 74 }
bhakti08 2:ef21b03bb9c2 75 /*****************************************************************************/
bhakti08 0:cdc96a6032be 76
bhakti08 2:ef21b03bb9c2 77 /*****************************************************************************/
bhakti08 2:ef21b03bb9c2 78 /* ISR to update selection */
bhakti08 2:ef21b03bb9c2 79 /*Function: Allows the user to toggle between the hours and minutes */
bhakti08 2:ef21b03bb9c2 80 /*****************************************************************************/
bhakti08 0:cdc96a6032be 81 void select_time()
bhakti08 0:cdc96a6032be 82 {
bhakti08 0:cdc96a6032be 83 selection = !selection;
bhakti08 0:cdc96a6032be 84 }
bhakti08 2:ef21b03bb9c2 85 /*****************************************************************************/
bhakti08 0:cdc96a6032be 86
bhakti08 2:ef21b03bb9c2 87 /*****************************************************************************/
bhakti08 2:ef21b03bb9c2 88 /* Thread to update LCD */
bhakti08 2:ef21b03bb9c2 89 /*Function: This thread updates the LCD with the actual and the alarm time */
bhakti08 2:ef21b03bb9c2 90 /*****************************************************************************/
bhakti08 0:cdc96a6032be 91 void update_lcd(void const *args)
bhakti08 0:cdc96a6032be 92 {
bhakti08 2:ef21b03bb9c2 93 M_lcd.lock(); //Mutex to lock the LCD
bhakti08 0:cdc96a6032be 94 lcd.cls();
bhakti08 0:cdc96a6032be 95 lcd.locate(0,20);
bhakti08 0:cdc96a6032be 96 while(1) {
bhakti08 0:cdc96a6032be 97 lcd.cls();
bhakti08 0:cdc96a6032be 98 lcd.locate(0,0);
bhakti08 0:cdc96a6032be 99 lcd.printf("Actual-hh:mm:sec %02d:%02d:%02d",hrs_set,mins_set,sec_set);
bhakti08 0:cdc96a6032be 100 lcd.locate(0,10);
bhakti08 0:cdc96a6032be 101 lcd.printf("Alarm-hh:mm:sec %02d:%02d:%02d",hrs,mins,0);
bhakti08 0:cdc96a6032be 102 M_lcd.unlock();
bhakti08 0:cdc96a6032be 103 Thread::wait(25);
bhakti08 0:cdc96a6032be 104 }
bhakti08 0:cdc96a6032be 105 }
bhakti08 2:ef21b03bb9c2 106 /*****************************************************************************/
bhakti08 0:cdc96a6032be 107
bhakti08 2:ef21b03bb9c2 108 /*****************************************************************************/
bhakti08 2:ef21b03bb9c2 109 /* Ticker function to update the actual time */
bhakti08 2:ef21b03bb9c2 110 /*This function is called every second. It increments no. of seconds */
bhakti08 2:ef21b03bb9c2 111 /*Also checks for max secs, mins and hours and accordingly adjusts other */
bhakti08 2:ef21b03bb9c2 112 /*variables. */
bhakti08 2:ef21b03bb9c2 113 /*****************************************************************************/
bhakti08 0:cdc96a6032be 114 void time_update()
bhakti08 0:cdc96a6032be 115 {
bhakti08 0:cdc96a6032be 116 sec_set++;
bhakti08 0:cdc96a6032be 117 if (sec_set == MAX_MINS)
bhakti08 0:cdc96a6032be 118 {
bhakti08 0:cdc96a6032be 119 mins_set++;
bhakti08 0:cdc96a6032be 120 sec_set = 0;
bhakti08 0:cdc96a6032be 121 }
bhakti08 0:cdc96a6032be 122 if (mins_set == MAX_MINS)
bhakti08 0:cdc96a6032be 123 {
bhakti08 0:cdc96a6032be 124 hrs_set++;
bhakti08 0:cdc96a6032be 125 mins_set = 0;
bhakti08 0:cdc96a6032be 126 }
bhakti08 0:cdc96a6032be 127 if (hrs_set == MAX_HRS)
bhakti08 0:cdc96a6032be 128 {
bhakti08 0:cdc96a6032be 129 hrs_set = 0;
bhakti08 0:cdc96a6032be 130 mins_set = 0;
bhakti08 0:cdc96a6032be 131 sec_set = 0;
bhakti08 0:cdc96a6032be 132 }
bhakti08 0:cdc96a6032be 133 }
bhakti08 2:ef21b03bb9c2 134 /*****************************************************************************/
bhakti08 2:ef21b03bb9c2 135
bhakti08 2:ef21b03bb9c2 136 /*****************************************************************************/
bhakti08 2:ef21b03bb9c2 137 /* Function to sound the alarm */
bhakti08 2:ef21b03bb9c2 138 /*This function is called when the alarm time = actual time */
bhakti08 2:ef21b03bb9c2 139 /*It sounds the alarm till alarm_stop button is pressed | 1 min is ellapsed */
bhakti08 2:ef21b03bb9c2 140 /*The variable frequency and beat rate of the PWM decide the tone of alarm */
bhakti08 2:ef21b03bb9c2 141 /*****************************************************************************/
bhakti08 2:ef21b03bb9c2 142 void alarm_on()
bhakti08 2:ef21b03bb9c2 143 {
bhakti08 2:ef21b03bb9c2 144 float frequency[]={659,554,659,554,440,494,554,587,494,659,554,440};
bhakti08 2:ef21b03bb9c2 145 float beat[]={1,1,1,1,1,0.5,0.5,1,1,1,1,2}; //beat array
bhakti08 2:ef21b03bb9c2 146 while (!stop_alarm && !(hrs_set == hrs && mins_set == mins+DURATION)) {
bhakti08 2:ef21b03bb9c2 147 wake_up = 1;
bhakti08 2:ef21b03bb9c2 148 for (int i=0;i<=11;i++) {
bhakti08 2:ef21b03bb9c2 149 speaker.period(1/(2*frequency[i])); // set PWM period
bhakti08 2:ef21b03bb9c2 150 speaker=0.5; // set duty cycle
bhakti08 2:ef21b03bb9c2 151 wait(0.4*beat[i]); // hold for beat period
bhakti08 2:ef21b03bb9c2 152 }
bhakti08 2:ef21b03bb9c2 153 }
bhakti08 2:ef21b03bb9c2 154 wake_up =0; //Turn OFF visual alarm
bhakti08 2:ef21b03bb9c2 155 speaker = 0.0; //Turn OFF audio alarm
bhakti08 2:ef21b03bb9c2 156 }
bhakti08 2:ef21b03bb9c2 157 /*****************************************************************************/
bhakti08 2:ef21b03bb9c2 158
bhakti08 2:ef21b03bb9c2 159 /*****************************************************************************/
bhakti08 2:ef21b03bb9c2 160 /* Thread for time Comparison */
bhakti08 2:ef21b03bb9c2 161 /*This thread comapres the actual and the alarm time and calls the alarm */
bhakti08 2:ef21b03bb9c2 162 /*function when both the timings are equal. It also reset the alarm time */
bhakti08 2:ef21b03bb9c2 163 /*after the alarm is turned OFF(either by user or after a minute is ellapsed)*/
bhakti08 2:ef21b03bb9c2 164 /*****************************************************************************/
bhakti08 0:cdc96a6032be 165 void sound_alarm(void const *args)
bhakti08 0:cdc96a6032be 166 {
bhakti08 0:cdc96a6032be 167 while (true){
bhakti08 0:cdc96a6032be 168 if ((hrs == hrs_set && mins_set == mins && sec_set == 0) )
bhakti08 0:cdc96a6032be 169 {
bhakti08 0:cdc96a6032be 170 alarm_on();
bhakti08 0:cdc96a6032be 171 hrs = 0;
bhakti08 0:cdc96a6032be 172 mins = 0;
bhakti08 0:cdc96a6032be 173 }
bhakti08 0:cdc96a6032be 174 Thread::wait(50);
bhakti08 0:cdc96a6032be 175 }
bhakti08 0:cdc96a6032be 176 }
bhakti08 2:ef21b03bb9c2 177 /*****************************************************************************/
bhakti08 0:cdc96a6032be 178
bhakti08 2:ef21b03bb9c2 179 /*****************************************************************************/
bhakti08 2:ef21b03bb9c2 180 /* Main Thread */
bhakti08 2:ef21b03bb9c2 181 /*Initializes all the threads and the USB inerface. */
bhakti08 2:ef21b03bb9c2 182 /*This thread makes a blocking call to set the time. In this application */
bhakti08 2:ef21b03bb9c2 183 /*blocking call is used since the actual time is necessary parameter for the */
bhakti08 2:ef21b03bb9c2 184 /*alarm clock. Without the time alarm clock has no function to do. */
bhakti08 2:ef21b03bb9c2 185 /*****************************************************************************/
bhakti08 0:cdc96a6032be 186 int main() {
bhakti08 1:aa410246cf19 187 char ch;
bhakti08 0:cdc96a6032be 188 increase.attach(&increase_time);
bhakti08 0:cdc96a6032be 189 select.attach(&select_time);
bhakti08 0:cdc96a6032be 190 Thread compare_time (sound_alarm,NULL,osPriorityAboveNormal);
bhakti08 0:cdc96a6032be 191 Thread lcd_display(update_lcd,NULL, osPriorityAboveNormal);
bhakti08 1:aa410246cf19 192 serial.printf("\r\n");
bhakti08 1:aa410246cf19 193 serial.scanf("%c",&ch);
bhakti08 1:aa410246cf19 194 serial.printf("Set the hours\r\n");
bhakti08 1:aa410246cf19 195 do{
bhakti08 1:aa410246cf19 196 serial.scanf("%d",&hrs_set);
bhakti08 1:aa410246cf19 197 if (hrs_set > MAX_HRS)
bhakti08 1:aa410246cf19 198 serial.printf("Enter Valid hours\r\n");
bhakti08 2:ef21b03bb9c2 199 }while (hrs_set > MAX_HRS); //error checking for hours entered
bhakti08 1:aa410246cf19 200 serial.printf("Set mins\r\n");
bhakti08 1:aa410246cf19 201 do
bhakti08 1:aa410246cf19 202 {
bhakti08 1:aa410246cf19 203 serial.scanf("%d",&mins_set);
bhakti08 1:aa410246cf19 204 if (mins_set > MAX_MINS)
bhakti08 1:aa410246cf19 205 serial.printf("Enter Valid minutes\r\n");
bhakti08 2:ef21b03bb9c2 206 }while (mins_set > MAX_MINS); //error checking for minutes entered
bhakti08 0:cdc96a6032be 207 update_time.attach(&time_update,1);
bhakti08 0:cdc96a6032be 208 while(1)
bhakti08 0:cdc96a6032be 209 {
bhakti08 2:ef21b03bb9c2 210 Thread::wait(1000);
bhakti08 0:cdc96a6032be 211 }
bhakti08 0:cdc96a6032be 212 }