First, i am noob in arduino and just tinkering arduino.
i want to make a clock using :
- Arduino UNO
- RTC DS1307
- LCD 16*2 character
and using this library :
#include <Time.h>
#include <TimeAlarms.h>
#include <Wire.h>
#include <DS1307RTC.h>
#include <EEPROM.h>
#include <LiquidCrystal.h>
the purpose of my sketch :
- Read Serial data VB from VB to set RTC if Serial Header is 'T' => achieved
example : T1310258400 set RTC to July 10th 2011. 00:40:00 - Read Serial data VB from VB to write EEPROM if Serial Header is 'I'
example :
I180018050001180318080001
- then save :
- //room 1
-
- 18 to EEPROM address 200 ==> alarm start hour //room 1
-
- 00 to EEPROM address 201 ==> alarm start minute //room 1
-
- 18 to EEPROM address 202 ==> alarm stop hour //room 1
-
- 05 to EEPROM address 203 ==> alarm stop minute //room 1
-
- 00 to EEPROM address 204 ==> alarm interval hour //room 1
-
- 01 to EEPROM address 205 ==> alarm interval minute //room 1
- //room 2
-
- 18 to EEPROM address 206 ==> alarm start hour //room 2
-
- 03 to EEPROM address 207 ==> alarm start minute //room 2
-
- 18 to EEPROM address 208 ==> alarm stop hour //room 2
-
- 08 to EEPROM address 209 ==> alarm stop minute //room 2
-
- 00 to EEPROM address 210 ==> alarm interval hour //room 2
-
- 01 to EEPROM address 211 ==> alarm interval minute //room 2
- desired output:
- alarm in room 1 ring every 1 minutes since 18.00 up to 18.05
- alarm in room 2 ring every 1 minutes since 18.03 up to 18.08
I have asked my problems on this thread:
my progress is on that thread, as summary, my sketch only handle 1 room alarm
and my next step is design 2 alarm for 2 room that can have different "start, stop, and interval" alarm value.
the example application is clock in industry,
clock for staff (from 08.00 up to 14.00 = room 1), clock for machine operator (8 hour shift/day = room 2)
So, i figure out the code will be the same as mem's fragment before (Time and TimeAlarms Libraries – Ask here for help or suggestions - #6 by mem - Programming Questions - Arduino Forum), but something wrong when I run it.
and this is part of my sketch:
#include <Time.h>
#include <TimeAlarms.h>
AlarmID_t alarm1;
AlarmID_t alarm2;
void setup()
{
Serial.begin(9600);
lcd.begin(16,2);
setSyncProvider(RTC.get); // the function to get the time from the RTC
setSyncInterval(600);
lcd.clear();
//room 1
Alarm.alarmRepeat(18,00,00, Start1); //start room 1
Alarm.alarmRepeat(18,05,30, Stop1); // End room 1
alarm1 = Alarm.timerRepeat( 1 * SECS_PER_MIN, doRING1);
//room 2
Alarm.alarmRepeat(18,03,30, Start2); //start room 2
Alarm.alarmRepeat(18,08,30, EndIntSlave2); // End room 2
alarm2 = Alarm.timerRepeat( 1 * SECS_PER_MIN, doRING2);
}
void Start1()
{
Alarm.enable(alarm1); //room 1 start alarm
}
void Stop1()
{
Alarm.disable(alarm1);//room 1 stop alarm
}
void doRING1()
{
lcd.print("1111111111111111");//room 1 interval
}
void Start2()
{
Alarm.enable(alarm2);//room 2 start alarm
}
void Stop2()
{
Alarm.disable(alarm2);//room 2 stop alarm
}
void doRING2()
{
lcd.print("2222222222222222");//room 2 interval
}
...
loop, etc
and here's the output :
18.00.00 : room 1, start the alarm = as desired
18.00.50 : alarm 2 is ringing ======>>>> undesired output
18.01.00 : alarm 1 is ringing = as desired
18.01.50 : alarm 2 is ringing ======>>>> undesired output
18.02.00 : alarm 1 is ringing = as desired
18.02.50 : alarm 2 is ringing ======>>>> undesired output
. . .
18.03.30 : room 2, start the alarm = as desired
18.04.30 : alarm 2 is ringing = as desired
18.05.30 : room 1, stop the alarm = as desired
. . .
10.08.30 : room 2, stop the alarm = as desired
^^ thanks, and sorry for my english ^^
regards,
.cop.