aboutsummaryrefslogtreecommitdiff
path: root/arduino_sketch
diff options
context:
space:
mode:
authorElena ``of Valhalla'' Grandi <elena.valhalla@gmail.com>2012-01-02 22:17:29 +0100
committerElena ``of Valhalla'' Grandi <elena.valhalla@gmail.com>2012-01-02 22:17:29 +0100
commit038e0ba8909426236503afe454f0e072f49a2232 (patch)
tree394252843d0f09d6bedcfd9b3ea5aed37b16eaca /arduino_sketch
parent2b99bf003646de82a44be8ac2469e0bf4c67442e (diff)
Added pushbutton to stop the SED
Diffstat (limited to 'arduino_sketch')
-rw-r--r--arduino_sketch/fuzzy_alarm_clock_ds1307/fuzzy_alarm_clock_ds1307.pde24
1 files changed, 22 insertions, 2 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