diff options
-rw-r--r-- | arduino_sketch/fuzzy_alarm_clock_ds1307/fuzzy_alarm_clock_ds1307.pde | 32 |
1 files changed, 31 insertions, 1 deletions
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 <RealTimeClockDS1307.h> // 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: |