![](/media/cache/group/default_image.jpg.50x50_q85.jpg)
Alarm Clock
Fork of SmartRise_MBED by
Diff: main.cpp
- Revision:
- 3:51b248042aa0
- Parent:
- 2:261fce57a100
- Child:
- 4:33f3750fe70a
--- a/main.cpp Sun Jan 24 02:03:50 2016 +0000 +++ b/main.cpp Mon Jan 25 21:08:47 2016 +0000 @@ -1,22 +1,46 @@ //8.3 LCD control with MBED main. #include "mbed.h" -#include "LCD.h" #include "TextLCD.h" +#include "TimeControl.cpp" -TextLCD lcd(p27,p28,p23,p24,p25,p26); +TextLCD lcd(p27,p28,p23,p24,p25,p26); //RS E d1,d2,d3,d4 +DigitalIn HrAdjustUp(p6); +DigitalIn HrAdjustDown(p7); +DigitalIn MinAdjust(p8); //buttons for setting time and alarm +DigitalIn AlarmAdjust(p9); +Timer set; + +Serial pc(USBTX,USBRX); + +InterruptIn safetyOff(p5); + int main() { int Ahr,Amin; + Ahr=11;Amin=30; + set.start(); while(1) { time_t seconds = time(NULL); - Ahr=11;Amin=30; + char buffer[32]; strftime(buffer, 32, "%a%m/%d %I:%M%p", localtime(&seconds)); //day, #month/#day Hr:min (AP)M wait(0.1); - lcd.printf("%s Alarm:%I:%I", buffer, Ahr, Amin); + lcd.printf("%s Alarm-%2I:%.2I", buffer, Ahr, Amin); + time_t a=localtime(&seconds); pc.printf("%i",a); //current problem + void Alarm(void); + if(AlarmAdjust==1&&set.read()>0.3){ //to be in main to call alarm adjust + if(HrAdjustUp==1) {Ahr=Ahr+1;set.reset();} + if(HrAdjustDown==1) {Ahr=Ahr-1;set.reset();} + if(MinAdjust==1) {Amin=Amin+1;set.reset();} + if(Ahr>23) Ahr=0; + if(Amin>=60) Amin=0; + } + // if( Ahr=___&&Amin=((localtime(&secods)%3600)/60 ){ - wait(1); + + + } } \ No newline at end of file