Pages: [1]   Go Down
Author Topic: Setting Alarm Problem  (Read 1853 times)
0 Members and 1 Guest are viewing this topic.
0
Offline Offline
Newbie
*
Karma: 0
Posts: 16
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I want to set an alarm with a specified serially read time I've tried every thing i can ,I even created a new function inside the library but nothing get me there
I need Help

Code:
void loop() {
  
 digitalClockDisplay();
 Alarm.delay(1000);
    if (Serial.available()>0)
 {  
  
  char setString[TIME_SET_StrLen];
  int index = 0;
 char c = Serial.read();
 if( c != '[')
     return;  // first character must be opening square brackets
  do
  {
     c = Serial.read();
     if( isdigit(c))  // non numeric characters are discarded
       setString[index++] = c -'0'; // convert from ascii    
  }
  while (c != ']'); // wait for trailing square brackets

 int count = index;
  int element = 0;
  for( index = 0; index < count; index += 2)  // step through each pair of digits
  {
      int val = setString[index] * 10 + setString[index+1] ; // get the numeric value of the next pair of numbers
switch( element++){
        case  0 :  Hour = val; break;
        case  1 :  Minute = val; break;
        case  2 :  Second = val; break;
}  
} }  
  
 Serial.print(Hour );
  Serial.print(Minute);
   Serial.print(Second);
   Serial.println("go to school");
  
     Alarm.alarmRepeat(20,20,0, MorningAlarm);
      Alarm.alarmRepea(Hour,Minute,Second,EveningAlarm); // my new function it works fine but not with serial date
  
  }

the function on the library
Code:
AlarmID_t TimeAlarmsClass::alarmRepea(int H, int M, int S, OnTick_t onTickHandler){
     return create( AlarmHMS(H,M,S), onTickHandler, IS_ALARM, IS_REPEAT );
}
« Last Edit: January 22, 2011, 03:52:01 pm by cellage » Logged

Seattle, WA USA
Online Online
Brattain Member
*****
Karma: 631
Posts: 50098
Seattle, WA USA
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
but nothing get me there
What does the code you posted actually do? How does that differ from what you actually want it to do?

Give us a clue where the problem is/
Logged

0
Offline Offline
Newbie
*
Karma: 0
Posts: 16
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

i want to enter the values of hours,minutes,seconds from a serial interface (vb) and set the alarm on the value received , but the function
 Alarm.alarmRepeat(Hour,Minute,Second,EveningAlarm);

doesnt work unless it had a constant time value specified from within the  arduino [glow]and again i need to send the value from a vb[/glow]

so I was wondering if there is a way to set the alarm in another way

note: I use
#include <Time.h>  
#include <TimeAlarms.h>
Logged

Global Moderator
UK
Offline Offline
Brattain Member
*****
Karma: 308
Posts: 26471
I don't think you connected the grounds, Dave.
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

My phone browser doesn't show all your code but it looks like you're reading characters that may not be there.
Logged

"Pete, it's a fool looks for logic in the chambers of the human heart." Ulysses Everett McGill.
Do not send technical questions via personal messaging - they will be ignored.

Seattle, WA USA
Online Online
Brattain Member
*****
Karma: 631
Posts: 50098
Seattle, WA USA
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Serial data transmission is sssslllloooowwww, The Arduino is fast, by comparison. You should declare the array to hold the serial data as a global variable, and populate it in a while loop, until there is no more serial data or until the end-of-packet marker is received.
Logged

0
Offline Offline
Newbie
*
Karma: 0
Posts: 16
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I thought in a  different way without referencing to the alarm library and used a simple if-statement

Code:
  if (hour()== Hour &&  minute() == Minute)
   {
 
     EveningAlarm1();
   }
 

This is what i want , thanks for help and suggestions  smiley-grin
Logged

Pages: [1]   Go Up
Jump to: