From 4d178f384b38d1a25a6371b24aaa73801b3faf3b Mon Sep 17 00:00:00 2001 From: Elena ``of Valhalla'' Grandi Date: Mon, 19 Dec 2011 22:20:44 +0100 Subject: Added alarm (1 second ininterruptible ring) --- .../fuzzy_alarm_clock_ds1307.pde | 32 +++++++++++++++++++++- 1 file changed, 31 insertions(+), 1 deletion(-) (limited to 'arduino_sketch/fuzzy_alarm_clock_ds1307') diff --git a/arduino_sketch/fuzzy_alarm_clock_ds1307/fuzzy_alarm_clock_ds1307.pde b/arduino_sketch/fuzzy_alarm_clock_ds1307/fuzzy_alarm_clock_ds1307.pde index 8c24791..700e35e 100644 --- a/arduino_sketch/fuzzy_alarm_clock_ds1307/fuzzy_alarm_clock_ds1307.pde +++ b/arduino_sketch/fuzzy_alarm_clock_ds1307/fuzzy_alarm_clock_ds1307.pde @@ -3,7 +3,7 @@ #include // minutes of "dawn" before alarm -#define TIN 30 +#define TIN 2 // "dawn" + "daylight" #define TDAY 45 // "dawn" + "daylight" + blue blinding light @@ -17,6 +17,8 @@ #define YPIN 5 #define BPIN 6 +#define APIN 9 + int st = 0; // alarm status (minutes from alarm - TIN) char alarms[NALARMS][5]; // alarm settings char cmin; // current minute @@ -87,6 +89,9 @@ void loop () { if ( st > 0 ) { set_leds(); } + if ( st == TIN ) { + ring_alarm(); + } // wait about till the next second @@ -327,4 +332,29 @@ void set_leds() { } } +// PC speaker +// +void ring_alarm() { + analogWrite(APIN,8); + delay(500); + analogWrite(APIN,0); + delay(500); + analogWrite(APIN,16); + delay(500); + analogWrite(APIN,0); + delay(500); + analogWrite(APIN,32); + delay(500); + analogWrite(APIN,0); + delay(500); + analogWrite(APIN,64); + delay(500); + analogWrite(APIN,0); + delay(500); + analogWrite(APIN,128); + delay(500); + analogWrite(APIN,0); + delay(500); +} + // vim: set filetype=c: -- cgit v1.2.3