diff options
-rw-r--r-- | arduino_sketch/fuzzy_alarm_clock_ds1307/fuzzy_alarm_clock_ds1307.pde | 54 | ||||
-rw-r--r-- | schematics/fuzzy_alarm_clock_ds1307-cache.lib | 2 | ||||
-rw-r--r-- | schematics/fuzzy_alarm_clock_ds1307.sch | 171 |
3 files changed, 115 insertions, 112 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 8a88b38..c08bd6a 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 @@ -13,17 +13,22 @@ #define NALARMS 4 // pins and addressed -#define RPIN 3 -#define YPIN 5 -#define BPIN 6 +#define RPIN 5 +#define YPIN 6 +#define BPIN 9 -#define APIN 9 +#define APIN0 3 +#define APIN1 11 int st = 0; // alarm status (minutes from alarm - TIN) char alarms[NALARMS][5]; // alarm settings char cmin; // current minute int a = -1; // current alarm char dbg = 0; // print debug informations +bool ringing = false; // sound the alarm + +#define NFREQ 9 +int freq[] = { 255, 192, 128, 96, 64, 96, 128, 192, 255 }; // frequencies for the alarm void setup () { Serial.begin(9600); @@ -33,6 +38,11 @@ void setup () { pinMode(YPIN,OUTPUT); pinMode(BPIN,OUTPUT); + pinMode(APIN0,INPUT); + pinMode(APIN1,INPUT); + TCCR2A = _BV(COM2A0) | _BV(COM2B1) | _BV(WGM20); + TCCR2B = _BV(WGM22) | _BV(CS22); + digitalWrite(RPIN,255); digitalWrite(YPIN,255); digitalWrite(BPIN,0); @@ -90,9 +100,13 @@ void loop () { set_leds(); } if ( st == TIN ) { + ringing = true; + } else { + ringing = false; + } + if ( ringing ) { ring_alarm(); } - // wait about till the next second delay(1000); @@ -339,26 +353,14 @@ 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); + + pinMode(APIN1,OUTPUT); + for (int i=0; i<NFREQ ; i++) { + OCR2A = freq[i]; + delay(50); + } + pinMode(APIN1,INPUT); + } // vim: set filetype=c: diff --git a/schematics/fuzzy_alarm_clock_ds1307-cache.lib b/schematics/fuzzy_alarm_clock_ds1307-cache.lib index 0cda90f..76171f3 100644 --- a/schematics/fuzzy_alarm_clock_ds1307-cache.lib +++ b/schematics/fuzzy_alarm_clock_ds1307-cache.lib @@ -1,4 +1,4 @@ -EESchema-LIBRARY Version 2.3 Date: Tue 20 Dec 2011 11:43:38 CET +EESchema-LIBRARY Version 2.3 Date: Fri 23 Dec 2011 21:43:32 CET #encoding utf-8 # # ARDUINO_SHIELD diff --git a/schematics/fuzzy_alarm_clock_ds1307.sch b/schematics/fuzzy_alarm_clock_ds1307.sch index 981da57..9cf3e07 100644 --- a/schematics/fuzzy_alarm_clock_ds1307.sch +++ b/schematics/fuzzy_alarm_clock_ds1307.sch @@ -1,4 +1,4 @@ -EESchema Schematic File Version 2 date Tue 20 Dec 2011 11:43:38 CET +EESchema Schematic File Version 2 date Fri 23 Dec 2011 21:43:32 CET LIBS:power LIBS:device LIBS:transistors @@ -31,13 +31,14 @@ LIBS:contrib LIBS:valves LIBS:arduino_shieldsNCL LIBS:ds1307_pcf8583 -EELAYER 43 0 +LIBS:fuzzy_alarm_clock_ds1307-cache +EELAYER 25 0 EELAYER END $Descr A4 11700 8267 encoding utf-8 Sheet 1 1 Title "" -Date "20 dec 2011" +Date "23 dec 2011" Rev "" Comp "" Comment1 "" @@ -45,93 +46,93 @@ Comment2 "" Comment3 "" Comment4 "" $EndDescr -Connection ~ 3700 5900 +Connection ~ 9100 4100 Wire Wire Line - 3700 5900 3700 5100 + 8300 4100 9100 4100 +Connection ~ 9100 3600 Wire Wire Line - 3700 5100 3500 5100 -Connection ~ 9100 4300 + 8300 3600 9100 3600 Wire Wire Line - 9100 5900 9100 2700 + 9100 2400 9100 5900 Wire Wire Line - 9100 5900 1700 5900 + 9100 2400 6800 2400 Wire Wire Line - 1700 5900 1700 5100 -Connection ~ 9100 4000 + 6800 2400 6800 3100 Wire Wire Line - 9100 4100 8800 4100 + 6500 4100 6700 4100 Wire Wire Line - 9100 3600 7700 3600 + 6500 4000 7250 4000 Wire Wire Line - 9100 2700 6800 2700 + 6500 3600 6700 3600 Wire Wire Line - 6800 2700 6800 3100 + 7400 3200 7400 3400 Wire Wire Line - 6800 3100 6500 3100 + 2600 5100 2900 5100 Wire Wire Line - 6500 4300 6700 4300 + 1700 4700 1000 4700 +Connection ~ 2800 4500 Wire Wire Line - 6500 4100 7250 4100 + 2800 4200 2800 4500 +Connection ~ 3200 3600 Wire Wire Line - 6500 4000 6700 4000 + 3200 3700 3200 3600 Wire Wire Line - 7300 3400 7300 3600 + 1700 4500 1400 4500 Wire Wire Line - 1700 4900 1300 4900 + 1400 4500 1400 3600 Wire Wire Line - 1300 4900 1300 5300 + 1400 3600 4600 3600 Wire Wire Line - 1300 5300 1000 5300 -Connection ~ 3200 4500 + 2800 3700 2800 3600 +Connection ~ 2800 3600 Wire Wire Line - 3200 4200 3200 4700 + 2600 4500 3000 4500 Wire Wire Line - 3200 4500 4600 4500 + 3000 4500 3000 4600 Wire Wire Line - 3200 4700 2600 4700 + 3000 4600 4600 4600 Wire Wire Line - 4600 4600 3000 4600 + 2600 4700 3200 4700 Wire Wire Line - 3000 4600 3000 4500 + 3200 4500 4600 4500 Wire Wire Line - 3000 4500 2600 4500 -Connection ~ 2800 3600 + 3200 4700 3200 4200 +Connection ~ 3200 4500 Wire Wire Line - 2800 3700 2800 3600 + 1000 5300 1300 5300 Wire Wire Line - 4600 3600 1400 3600 + 1300 5300 1300 4900 Wire Wire Line - 1400 3600 1400 4500 + 1300 4900 1700 4900 Wire Wire Line - 1400 4500 1700 4500 + 6800 3100 6500 3100 Wire Wire Line - 3200 3700 3200 3600 -Connection ~ 3200 3600 + 1700 5100 1700 5900 Wire Wire Line - 2800 4200 2800 4500 -Connection ~ 2800 4500 + 1700 5900 9100 5900 Wire Wire Line - 1700 4700 1000 4700 + 3500 5100 3700 5100 Wire Wire Line - 7300 3600 6500 3600 + 3700 5100 3700 5900 +Connection ~ 3700 5900 Wire Wire Line - 7500 3400 7700 3400 + 7400 3400 6500 3400 Wire Wire Line - 7700 3400 7700 3600 + 7600 3200 7800 3200 Wire Wire Line - 7200 4000 7900 4000 + 7800 3200 7800 3400 Wire Wire Line - 7750 4100 8400 4100 + 7200 3600 7900 3600 Wire Wire Line - 7200 4300 7900 4300 + 7750 4000 8400 4000 Wire Wire Line - 9100 4000 8300 4000 -Connection ~ 9100 3600 + 7200 4100 7900 4100 Wire Wire Line - 9100 4300 8300 4300 -Connection ~ 9100 4100 + 7800 3400 9100 3400 +Connection ~ 9100 3400 Wire Wire Line - 2600 5100 2900 5100 + 8800 4000 9100 4000 +Connection ~ 9100 4000 $Comp L BATTERY BT? U 1 1 4EF0662F @@ -144,73 +145,73 @@ $EndComp $Comp L LED D? U 1 1 4EF065A1 -P 8100 4300 -F 0 "D?" H 8100 4400 50 0000 C CNN -F 1 "LED" H 8100 4200 50 0000 C CNN - 1 8100 4300 +P 8100 4100 +F 0 "D?" H 8100 4200 50 0000 C CNN +F 1 "LED R" H 8100 4000 50 0000 C CNN + 1 8100 4100 1 0 0 -1 $EndComp $Comp L LED D? U 1 1 4EF0659B -P 8600 4100 -F 0 "D?" H 8600 4200 50 0000 C CNN -F 1 "LED" H 8600 4000 50 0000 C CNN - 1 8600 4100 +P 8600 4000 +F 0 "D?" H 8600 4100 50 0000 C CNN +F 1 "LED Y" H 8600 3900 50 0000 C CNN + 1 8600 4000 1 0 0 -1 $EndComp $Comp L LED D? U 1 1 4EF06594 -P 8100 4000 -F 0 "D?" H 8100 4100 50 0000 C CNN -F 1 "LED" H 8100 3900 50 0000 C CNN - 1 8100 4000 +P 8100 3600 +F 0 "D?" H 8100 3700 50 0000 C CNN +F 1 "LED B" H 8100 3500 50 0000 C CNN + 1 8100 3600 1 0 0 -1 $EndComp $Comp L R R? U 1 1 4EF06585 -P 6950 4300 -F 0 "R?" V 7030 4300 50 0000 C CNN -F 1 "R" V 6950 4300 50 0000 C CNN - 1 6950 4300 +P 6950 4100 +F 0 "R?" V 7030 4100 50 0000 C CNN +F 1 "220" V 6950 4100 50 0000 C CNN + 1 6950 4100 0 1 1 0 $EndComp $Comp L R R? U 1 1 4EF06573 -P 7500 4100 -F 0 "R?" V 7580 4100 50 0000 C CNN -F 1 "R" V 7500 4100 50 0000 C CNN - 1 7500 4100 +P 7500 4000 +F 0 "R?" V 7580 4000 50 0000 C CNN +F 1 "220" V 7500 4000 50 0000 C CNN + 1 7500 4000 0 1 1 0 $EndComp $Comp L R R? U 1 1 4EF0655A -P 6950 4000 -F 0 "R?" V 7030 4000 50 0000 C CNN -F 1 "R" V 6950 4000 50 0000 C CNN - 1 6950 4000 +P 6950 3600 +F 0 "R?" V 7030 3600 50 0000 C CNN +F 1 "220" V 6950 3600 50 0000 C CNN + 1 6950 3600 0 -1 -1 0 $EndComp $Comp L CAPAPOL C? U 1 1 4EF06517 -P 7500 3600 -F 0 "C?" H 7550 3700 50 0000 L CNN -F 1 "CAPAPOL" H 7550 3500 50 0000 L CNN - 1 7500 3600 +P 7600 3400 +F 0 "C?" H 7650 3500 50 0000 L CNN +F 1 "CAPAPOL" H 7650 3300 50 0000 L CNN + 1 7600 3400 0 1 1 0 $EndComp $Comp L SPEAKER SP? U 1 1 4EF064D7 -P 7400 3100 -F 0 "SP?" H 7300 3350 70 0000 C CNN -F 1 "SPEAKER" H 7300 2850 70 0000 C CNN - 1 7400 3100 +P 7500 2900 +F 0 "SP?" H 7400 3150 70 0000 C CNN +F 1 "SPEAKER" H 7400 2650 70 0000 C CNN + 1 7500 2900 0 -1 -1 0 $EndComp $Comp @@ -227,7 +228,7 @@ L R R? U 1 1 4EF06349 P 2800 3950 F 0 "R?" V 2880 3950 50 0000 C CNN -F 1 "R" V 2800 3950 50 0000 C CNN +F 1 "2k2" V 2800 3950 50 0000 C CNN 1 2800 3950 1 0 0 -1 $EndComp @@ -236,7 +237,7 @@ L R R? U 1 1 4EF06341 P 3200 3950 F 0 "R?" V 3280 3950 50 0000 C CNN -F 1 "R" V 3200 3950 50 0000 C CNN +F 1 "2k2" V 3200 3950 50 0000 C CNN 1 3200 3950 1 0 0 -1 $EndComp |