i have tried this code to set the alarm but got error in this ..
can i use this code to set alarm time
//Program
[size=10pt][size=10pt][size=10pt][size=10pt][size=10pt]#include <Time.h>
#include <TimeAlarms.h>
#include <virtuabotixRTC.h>
virtuabotixRTC myRTC(6, 7, 8);
char requestBuffer[100];
int requestIdx=0;
int hour=8 ;
int minute=0;
int second=0;
int input;
void setup()
{
Serial.begin(9600);
// pinMode(led,OUTPUT);
setTime(8,0,0,16,7,14);
myRTC.setDS1302Time(00, 00, 8, 3, 14, 7, 2014);}
void loop()
{
myRTC.updateTime();
Serial.print("Current Date / Time: ");
Serial.print(myRTC.dayofmonth);
Serial.print("/");
Serial.print(myRTC.month);
Serial.print("/");
Serial.print(myRTC.year);
Serial.print(" ");
Serial.print(myRTC.hours);
Serial.print(":");
Serial.print(myRTC.minutes);
Serial.print(":");
Serial.println(myRTC.seconds);
// Start printing elements as individuals
Alarm.delay(1000); // wait one second between clock display
//if (Serial.available() >0)
hi ();
Alarm.alarmRepeat(hour,minute,second, morningalarm);
}
void hi ()
{
if(Serial.available()){ // extremely primitive command decoder
char c = Serial.read();
switch(c){
case '\r': // carriage return, process string
requestBuffer[requestIdx++] = c; // save the character
requestBuffer[requestIdx] = '\0'; // terminate the request with a null so the various routines work
Serial.println(requestBuffer); // this just shows you what you have
// now do something with the request string
processRequest(requestBuffer, strlen(requestBuffer));
//start collecting the next request string
memset(requestBuffer,0,sizeof(requestBuffer)); //start off empty
requestIdx = 0; // and at the beginning
break;
default:
requestBuffer[requestIdx] = c; // this saves it one character at a time
if(requestIdx < sizeof(requestBuffer)) // if they typed in too many characters
requestIdx++;
else{ //the buffer filled up with garbage
memset(requestBuffer,0,sizeof(requestBuffer)); //start off empty
requestIdx = 0; // and at the beginning
}
break;
}
}
void processRequest(char *buf){
hour = strtok(buf, ","); // get the first comma delimited item from the request
minute = strtok(0, ","); // and the next one, which should be month
second = strtok(0,"," );
}
void morningalarm(){
Serial.println("Alarm: - turn lights off");
// digitalWrite(led, HIGH);
}
[/size][/size][/size][/size][/size]
// i got the following errors
set_alarm:7: error: 'int hour' redeclared as different kind of symbol
C:\Users\Aisha aslam\Documents\Arduino\libraries\Time/Time.h:100: error: previous declaration of 'int hour(time_t)'
set_alarm:8: error: 'int minute' redeclared as different kind of symbol
C:\Users\Aisha aslam\Documents\Arduino\libraries\Time/Time.h:108: error: previous declaration of 'int minute(time_t)'
set_alarm:9: error: 'int second' redeclared as different kind of symbol
C:\Users\Aisha aslam\Documents\Arduino\libraries\Time/Time.h:110: error: previous declaration of 'int second(time_t)'
set_alarm.ino: In function 'void loop()':
set_alarm:37: error: no matching function for call to 'TimeAlarmsClass::alarmRepeat(<unresolved overloaded function type>, <unresolved overloaded function type>, <unresolved overloaded function type>, void (&)())'
C:\Users\Aisha aslam\Documents\Arduino\libraries\TimeAlarms/TimeAlarms.h:69: note: candidates are: AlarmID_t TimeAlarmsClass::alarmRepeat(time_t, void (*)())
C:\Users\Aisha aslam\Documents\Arduino\libraries\TimeAlarms/TimeAlarms.h:70: note: AlarmID_t TimeAlarmsClass::alarmRepeat(int, int, int, void (*)())
C:\Users\Aisha aslam\Documents\Arduino\libraries\TimeAlarms/TimeAlarms.h:71: note: AlarmID_t TimeAlarmsClass::alarmRepeat(timeDayOfWeek_t, int, int, int, void (*)())
set_alarm.ino: In function 'void hi()':
set_alarm:9: error: too many arguments to function 'void processRequest(char*)'
set_alarm:49: error: at this point in file
set_alarm:66: error: a function-definition is not allowed here before '{' token
set_alarm:71: error: a function-definition is not allowed here before '{' token
set_alarm:75: error: expected `}' at end of input