Go Down

Topic: Time and TimeAlarms Libraries – Ask here for help or suggestions (Read 123868 times) previous topic - next topic

AviG

I am trying to print out the time every second, but it isn't working. Please help.
Code: [Select]

#include <Time.h>
#include <TimeLib.h>

void setup() {
  Serial.begin(9600);
}

void loop() {
  Serial.print("It is " + hour() + ':' + minute() + ':' + second());
  delay(1000);
}

UKHeliBob

Please do not send me PMs asking for help.  Post in the forum then everyone will benefit from seeing the questions and answers.

Welsyntoffie

Hi.
First all, nice library.
I want to know how can I change the alarm time during runtime.
If I have a variable...
Int hourset = 0
This variable will be able to change with a pushbutton +1 or -1.
If I do this... alarmrepeat(hourset,0,0, function) then the alarm does not trigger.
How can make this work?
I do not want to reprogram my arduino for a time alarm time. I have been looking at another thread that when dormant in 2010 but its still unclear to me.

Hassiebassie

Hi,
I'm having troubles using the time library.
I'm using the 1.6.11 SDK.

1st attempt:
At first I used the installer found on http://www.pjrc.com/teensy/td_libs_Time.html
(I downloaded the Beta, that's the one that supports 1.6.11).

It installed fine. My code won't compile:
#include <time.h>

void setup() {
  // put your setup code here, to run once:
  Serial.begin(9600);      // open the serial port at 9600 bps:
  Serial.println("Running...");
}

int CurrentTime;

void loop() {
  // put your main code here, to run repeatedly:
  CurrentTime = now();
  Serial.println(CurrentTime);
  delay(1000);  // Wait a second
}

The error I get:
'now' was not declared in this scope

Seems to me that the library was not installed properly.


I Appreciate your help

UKHeliBob

Code: [Select]
#include <time.h>Is the file called time.h or Time.h ?
Please do not send me PMs asking for help.  Post in the forum then everyone will benefit from seeing the questions and answers.

Hassiebassie

Yep, that's it. I changed it to <Time.h>.
That solved this issue.
Thanks

RazielReaver

there is anyway to send a variable in the alarms?? like in example


id[0] = Alarm.alarmRepeat(17,0,0, SensorperHour(0));

UKHeliBob

Are you wanting to get the ID of the alarm into a variable or use a variable as one of the alarm parameters ?

What have you tried ?
Please do not send me PMs asking for help.  Post in the forum then everyone will benefit from seeing the questions and answers.

Go Up
 


Please enter a valid email to subscribe

Confirm your email address

We need to confirm your email address.
To complete the subscription, please click the link in the email we just sent you.

Thank you for subscribing!

Arduino
via Egeo 16
Torino, 10131
Italy