From 106f71397f8451a927d17627aae1a1e87c776ad9 Mon Sep 17 00:00:00 2001 From: Elena ``of Valhalla'' Grandi Date: Wed, 4 Apr 2012 08:38:35 +0200 Subject: arduino sketch: fix ringing and other times. The ringing, blue light and off time were off by 1 minute. --- .../fuzzy_alarm_clock_ds1307/fuzzy_alarm_clock_ds1307.pde | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'arduino_sketch') 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 12ff745..9735508 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 @@ -129,7 +129,7 @@ void loop () { if ( st > 0 ) { set_leds(); } - if ( st == TIN ) { + if ( st == TIN + 1) { if ( RTC.getSeconds() < 5 ) { ringing = true; } @@ -417,19 +417,19 @@ void check_time() { void set_leds() { if ( st > 0 && st <= TIN) { - int y = int(float(st*255)/TIN); + int y = int(float(st*255)/(TIN+1)); int r = 255 - y; analogWrite(RPIN,r); analogWrite(YPIN,y); - } else if ( st > TIN && st < TDAY ) { + } else if ( st > TIN && st <= TDAY ) { analogWrite(RPIN,0); analogWrite(YPIN,255); analogWrite(BPIN,0); - } else if (st >= TDAY && st < TOUT) { + } else if ( st > TDAY && st <= TOUT ) { analogWrite(RPIN,0); analogWrite(YPIN,0); analogWrite(BPIN,255); - } else if (st == TOUT) { + } else if ( st == TOUT + 1 ) { // reset stuff st = 0; a = -1; -- cgit v1.2.3