From 038e0ba8909426236503afe454f0e072f49a2232 Mon Sep 17 00:00:00 2001 From: Elena ``of Valhalla'' Grandi Date: Mon, 2 Jan 2012 22:17:29 +0100 Subject: [PATCH] Added pushbutton to stop the SED --- .../fuzzy_alarm_clock_ds1307.pde | 24 ++++++++++++++-- schematics/fuzzy_alarm_clock_ds1307-cache.lib | 15 +++++++++- schematics/fuzzy_alarm_clock_ds1307.sch | 33 ++++++++++++++++++++-- 3 files changed, 67 insertions(+), 5 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 a4e0040..9b2e0c9 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 @@ -38,12 +38,16 @@ #define APIN0 3 #define APIN1 11 +#define IINT 0 +#define IPIN 2 + 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 +bool pressed = false; // stop button status #define NFREQ 9 int freq[] = { 255, 192, 128, 96, 64, 96, 128, 192, 255 }; // frequencies for the alarm @@ -61,6 +65,8 @@ void setup () { TCCR2A = _BV(COM2A0) | _BV(COM2B1) | _BV(WGM20); TCCR2B = _BV(WGM22) | _BV(CS22); + attachInterrupt(IINT, button_pressed, HIGH); + digitalWrite(RPIN,HIGH); digitalWrite(YPIN,LOW); digitalWrite(BPIN,LOW); @@ -110,7 +116,11 @@ void loop () { Serial.print(", a: "); Serial.print(a,DEC); Serial.print(", cmin: "); - Serial.println(cmin,DEC); + Serial.print(cmin,DEC); + Serial.print(", ringing: "); + Serial.print(ringing); + Serial.print(", pressed: "); + Serial.println(pressed); } // act on status: LEDs and buzzer @@ -118,9 +128,15 @@ void loop () { set_leds(); } if ( st == TIN ) { - ringing = true; + if ( RTC.getSeconds() < 5 ) { + ringing = true; + } + if ( pressed ) { + ringing = false; + } } else { ringing = false; + pressed = false; } if ( ringing ) { ring_alarm(); @@ -301,6 +317,10 @@ void s_print_help() { Serial.println(" h - print this help"); } +void button_pressed() { + pressed = true; +} + // ****** Time management *************************************************** // // Set the current time diff --git a/schematics/fuzzy_alarm_clock_ds1307-cache.lib b/schematics/fuzzy_alarm_clock_ds1307-cache.lib index 76171f3..984d5e3 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: Fri 23 Dec 2011 21:43:32 CET +EESchema-LIBRARY Version 2.3 Date: Mon 02 Jan 2012 21:02:29 CET #encoding utf-8 # # ARDUINO_SHIELD @@ -167,4 +167,17 @@ X 2 2 -300 -100 200 R 40 40 1 1 I ENDDRAW ENDDEF # +# SW_PUSH +# +DEF SW_PUSH SW 0 40 N N 1 F N +F0 "SW" 150 110 50 H V C CNN +F1 "SW_PUSH" 0 -80 50 H V C CNN +DRAW +S -170 50 170 60 0 1 0 N +P 4 0 1 0 -40 60 -30 90 30 90 40 60 N +X 1 1 -300 0 200 R 60 60 0 1 P I +X 2 2 300 0 200 L 60 60 0 1 P I +ENDDRAW +ENDDEF +# #End Library diff --git a/schematics/fuzzy_alarm_clock_ds1307.sch b/schematics/fuzzy_alarm_clock_ds1307.sch index 9cf3e07..737da25 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 Fri 23 Dec 2011 21:43:32 CET +EESchema Schematic File Version 2 date Mon 02 Jan 2012 21:02:29 CET LIBS:power LIBS:device LIBS:transistors @@ -38,7 +38,7 @@ $Descr A4 11700 8267 encoding utf-8 Sheet 1 1 Title "" -Date "23 dec 2011" +Date "2 jan 2012" Rev "" Comp "" Comment1 "" @@ -46,6 +46,9 @@ Comment2 "" Comment3 "" Comment4 "" $EndDescr +Connection ~ 9100 4400 +Wire Wire Line + 7900 4400 9100 4400 Connection ~ 9100 4100 Wire Wire Line 8300 4100 9100 4100 @@ -133,6 +136,32 @@ Connection ~ 9100 3400 Wire Wire Line 8800 4000 9100 4000 Connection ~ 9100 4000 +Wire Wire Line + 4350 3600 4350 5000 +Wire Wire Line + 4350 5000 7000 5000 +Connection ~ 4350 3600 +Wire Wire Line + 7400 4400 6500 4400 +Connection ~ 7000 4400 +$Comp +L SW_PUSH SW? +U 1 1 4F020CFA +P 7000 4700 +F 0 "SW?" H 7150 4810 50 0000 C CNN +F 1 "SW_PUSH" H 7000 4620 50 0000 C CNN + 1 7000 4700 + 0 1 1 0 +$EndComp +$Comp +L R R? +U 1 1 4F020CCF +P 7650 4400 +F 0 "R?" V 7730 4400 50 0000 C CNN +F 1 "R" V 7650 4400 50 0000 C CNN + 1 7650 4400 + 0 1 1 0 +$EndComp $Comp L BATTERY BT? U 1 1 4EF0662F -- 2.11.4.GIT