Error message that I don't understand

Hello,

I'm trying to get this Garduino code compiled but I don't really understand the (probably simple) error message and was wondering if someone could help me out please.

#include <Time.h>

//define analog inputs to which we have connected our sensors
int moistureSensor = 0;
int lightSensor = 1;
int tempSensor = 2;

//define digital outputs to which we have connecte our relays (water and light) and LED (temperature)
int waterPump = 7;
int lightSwitch = 8;
int tempLed = 2;

//define variables to store moisture, light, and temperature values
int moisture_val;
int light_val;
int temp_val;

//decide how many hours of light your plants should get daily
float hours_light_daily_desired = 14;

//calculate desired hours of light total and supplemental daily based on above values
float proportion_to_light = hours_light_daily_desired / 24;
float seconds_light = 0;
float proportion_lit;

//setup a variable to store seconds since arduino switched on
float start_time;
float seconds_elapsed;
float seconds_elapsed_total;
float seconds_for_this_cycle;

void setup() {
//open serial port
Serial.begin(9600);
//set the water, light, and temperature pins as outputs that are turned off
pinMode (waterPump, OUTPUT);
pinMode (lightSwitch, OUTPUT);
pinMode (tempLed, OUTPUT);
digitalWrite (waterPump, LOW);
digitalWrite (lightSwitch, LOW);
digitalWrite (tempLed, LOW);

//establish start time
start_time = Time.now();
seconds_elapsed_total = 0;

}
void loop() {
// read the value from the moisture-sensing probes, print it to screen, and wait a second
moisture_val = analogRead(moistureSensor);
Serial.print("moisture sensor reads ");
Serial.println( moisture_val );
delay(1000);
// read the value from the photosensor, print it to screen, and wait a second
light_val = analogRead(lightSensor);
Serial.print("light sensor reads ");
Serial.println( light_val );
delay(1000);
// read the value from the temperature sensor, print it to screen, and wait a second
temp_val = analogRead(tempSensor);
Serial.print("temp sensor reads ");
Serial.println( temp_val );
delay(1000);
Serial.print("seconds total = ");
Serial.println( seconds_elapsed_total );
delay(1000);
Serial.print("seconds lit = ");
Serial.println( seconds_light);
delay(1000);
Serial.print("proportion desired = ");
Serial.println( proportion_to_light);
delay(1000);
Serial.print("proportion achieved = ");
Serial.println( proportion_lit);
delay(1000);

//turn water on when soil is dry, and delay until soil is wet
if (moisture_val < 850)
{
digitalWrite(waterPump, HIGH);
}

while (moisture_val < 850)
{
delay(10000);
}

digitalWrite(waterPump, LOW);

//update time, and increment seconds_light if the lights are on
seconds_for_this_cycle = Time.now() - seconds_elapsed_total;
seconds_elapsed_total = Time.now() - start_time;
if (light_val > 900)
{
seconds_light = seconds_light + seconds_for_this_cycle;
}

//cloudy days that get sunny again: turn lights back off if light_val exceeds 900. this works b/c the supplemental lights aren't as bright as the sun:)
if (light_val > 900)
{
digitalWrite (lightSwitch, LOW);
}

//turn off lights if proportion_lit>proportion_to_light, and then wait 5 minutes
if (proportion_lit > proportion_to_light)
{
digitalWrite (lightSwitch, LOW);
delay (300000);
}

//figure out what proportion of time lights have been on
proportion_lit = seconds_light/seconds_elapsed_total;

//turn lights on if light_val is less than 900 and plants have light for less than desired proportion of time, then wait 10 seconds
if (light_val < 900 and proportion_lit < proportion_to_light)
{
digitalWrite(lightSwitch, HIGH);
delay(10000);
}

//turn on temp alarm light if temp_val is less than 850 (approximately 50 degrees Fahrenheit)
if (temp_val < 850)
{
digitalWrite(tempLed, HIGH);
}

}

What error message?

I'm sorry that I forgot the most important part of my question. Here is the error message:

sketch_sep08b.cpp: In function 'void setup()':
sketch_sep08b:44: error: 'Time' was not declared in this scope
sketch_sep08b.cpp: In function 'void loop()':
sketch_sep08b:91: error: 'Time' was not declared in this scope

change all references to Time.now() with millis() and it will compile.

Looks like there was a Time class at some point that you don't have in there.

As for it working for what you want.. i have no idea.

#include <Time.h>
I was gonna say you probably need to include the Time library in your arduino/library folder.

CrossRoads:
#include <Time.h>
I was gonna say you probably need to include the Time library in your arduino/library folder.

Never used the time library personally so it didn't even cross my mind. Good call.

CrossRoads:
#include <Time.h>
I was gonna say you probably need to include the Time library in your arduino/library folder.

I have this in my code (first line).

You don't understand.
Yes, you are calling out the library Time.h in your sketch,

You do not have C:\ ... \Arduino-1.0.1\library\Time in place.

It's there because I included it through the import feature from the IDE's menu. I downloaded the time library before and extracted it into my library folder and made sure the top-level time folder contains the files so it can show up under the import sub-menu.

Does Time.now() add any value over a straight forward call to millis()? I'm wondering what the point of using it is.

Got me stumped then.

start_time = Time.now();
sketch_sep08b:44: error: 'Time' was not declared in this scope

Have you looked at any of the examples supplied with the Time library? They don't use now() like that. Here is a snippet from TimeNTP:

void loop()
{  
  if( now() != prevDisplay) //update the display only if the time has changed
  {
    prevDisplay = now();
    digitalClockDisplay();  
  }
}

See Arduino Playground - Time for additional information.

None of the Time-examples work. And when you look around online, nobody is really able to use their examples. I'll try "now" instead of Time.now()

Well, TimeSerial and TimeSerialDateStrings certainly work. I added Serial.println(now()); and that worked too.

If TimeSerial doesn't work for you, then the library is not in the right place. Show us the complete path to the file Time.h.

C:\Program Files\arduino-1.0.1\libraries\Time\Time.h (..\Time.cpp, ..\DateStrings.CPP respectively).

C:\Program Files\arduino-1.0.1\libraries is for Arduino-provide libraries, NOT user downloaded libraries.

Eliminating Time. did the trick. I can at least verify and compile the code now.

PaulS:
C:\Program Files\arduino-1.0.1\libraries is for Arduino-provide libraries, NOT user downloaded libraries.

So what do you suggest to a Arduino programmer newbie?

Reading the provided documentation.

Contributed Libraries

If you're using one of these libraries, you need to install it first. To do so, download the library and unzip it. It should be in a folder of its own, and will typically contain at least two files, one with a .h suffix and one with a .cpp suffix. Open your Arduino sketchbook folder. If there is already a folder there called libraries, place the library folder in there. If not, create a folder called libraries in the sketchbook folder, and drop the library folder in there. Then re-start the Arduino programming environment, and you should see your new library in the Sketch > Import Library menu.

http://arduino.cc/en/Guide/Environment#libraries

Libraries

Libraries provide extra functionality for use in sketches, e.g. working with hardware or manipulating data. To use a library in a sketch, select it from the Sketch > Import Library menu. This will insert one or more #include statements at the top of the sketch and compile the library with your sketch. Because libraries are uploaded to the board with your sketch, they increase the amount of space it takes up. If a sketch no longer needs a library, simply delete its #include statements from the top of your code.

There is a list of libraries in the reference. Some libraries are included with the Arduino software. Others can be downloaded from a variety of sources. To install these third-party libraries, create a directory called libraries within your sketchbook directory. Then unzip the library there. For example, to install the DateTime library, its files should be in the /libraries/DateTime sub-folder of your sketchbook folder.