Pages: [1]   Go Down
Author Topic: time.h with 1.0.1?  (Read 4552 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Sr. Member
****
Karma: 6
Posts: 429
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Code:
// Simple Time using Time.h

#include <time.h>

void setup() {
  // put your setup code here, to run once:
setTime(10,62,23,47,2,12);
}

void loop() {
  // put your main code here, to run repeatedly:
 
  Serial.println(hour());
  Serial.print(":");
  Serial.println(minute());
  Serial.println("");
  delay(1000);
}
error is setTime was not declared in this scope.

The TimeSerial example give an error of time_t does not name a type.
Logged

Leeds, UK
Offline Offline
Edison Member
*
Karma: 80
Posts: 1730
Once the magic blue smoke is released, it won't go back in!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

You need:
Code:
#include <Time.h>
Not:
Code:
#include <time.h>


time.h is a C library which is totally different from Time.h which is a arduino library (whoever named a library the same as a one of the C base libraries differing by a capital letter should be should be given a stern talking to!!)
« Last Edit: October 05, 2012, 07:04:42 pm by Tom Carpenter » Logged

~Tom~

Offline Offline
Sr. Member
****
Karma: 6
Posts: 429
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Thanks for the quick reply, changed time.h to Time.h and it still gives the same error.
Logged

Leeds, UK
Offline Offline
Edison Member
*
Karma: 80
Posts: 1730
Once the magic blue smoke is released, it won't go back in!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Have you downloaded this:
http://www.arduino.cc/playground/Code/Time
Logged

~Tom~

Offline Offline
Sr. Member
****
Karma: 6
Posts: 429
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Yes, but I see what I did wrong.

I alway download stuff to my desktop and extract to a folder first, (just in case the zip file does not extract to it own folder), in this case, you have to put the zip file into the library folder and extract it there.

The TimeSerial example uses the Serial.print(TIME_REQUEST.BYTE); which is no longer supported, but thats easily fixed.

Edit: Here`s some very basic example code, for proper formatting see the included TimeSerial example.
Code:
// Simple Time using Time.h

//Basic Time example, does very little foramtting of the output.
//See the included TimeSerial Example for formatted output.
#include <Time.h>

void setup() {
  //setTime(hr,min,sec,day,month,yr); 13:15:10 6/10/12
  setTime(13,15,10,06,10,12);
  
  Serial.begin(1200);
  Serial.println("Serial Connected");
}

void loop() {
  Serial.print("The Day is ");
  Serial.println(day());
  Serial.print("The Month is ");  
  Serial.println(month());
  Serial.print("The Year is ");  
  Serial.println(year());
  Serial.println("");
  
  Serial.println("The Time is ");
  Serial.print(hour());
  Serial.print(":");
  Serial.print(minute());
  Serial.print(":");  
  Serial.println(second());
  Serial.println("");

  delay(5000);
}
« Last Edit: October 06, 2012, 04:45:25 am by Lakes » Logged

Grand Blanc, MI, USA
Offline Offline
Faraday Member
**
Karma: 95
Posts: 4094
CODE is a mass noun and should not be used in the plural or with an indefinite article.
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

I alway download stuff to my desktop and extract to a folder first, (just in case the zip file does not extract to it own folder), in this case, you have to put the zip file into the library folder and extract it there.

Why is this the case? I'm trying to understand the solution here because I've had inquiries from a couple people that seem to have similar issues with the Time library. I have not been able to duplicate the symptoms myself. Like you, sometimes I'll download a library elsewhere then move it into the library folder, but other times not. I'm not seeing why it should make a difference.

Thanks!
Logged

MCP79411/12 RTC ... "One Million Ohms" ATtiny kit ... available at http://www.tindie.com/stores/JChristensen/

Offline Offline
Sr. Member
****
Karma: 6
Posts: 429
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

 I think its because there`s Time *and*  TimeAlarms folders in the zipfile.
Logged

Pages: [1]   Go Up
Jump to: