Garduino Code Errors


hi,

      know there lot of posts out there people tried build "garduino" arduino based plant watering system haven't seen me specific problem. i'm using code found here: http://archive.makezine.com/18/garduino/

i've tried code #include <datetime.h> , #include <time.h> trying them together.

code: [select]
//include datetime library, our garduino can keep track of how long lights on
#include

//define analog inputs have connected our sensors
int moisturesensor = 0;
int lightsensor = 1;
int tempsensor = 2;

//define digital outputs have connecte our relays (water , light) , led (temperature)
int waterpump = 7;
int lightswitch = 8;
int templed = 2;

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

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

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

//setup variable 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 water, light, , temperature pins outputs 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 = datetime.now();
seconds_elapsed_total = 0;

}
void loop() {
// read value moisture-sensing probes, print screen, , wait second
moisture_val = analogread(moisturesensor);
serial.print("moisture sensor reads ");
serial.println( moisture_val );
delay(1000);
// read value photosensor, print screen, , wait second
light_val = analogread(lightsensor);
serial.print("light sensor reads ");
serial.println( light_val );
delay(1000);
// read value temperature sensor, print screen, , wait 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 dry, , delay until soil wet
if (moisture_val < 850)
{
digitalwrite(waterpump, high);
}

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

digitalwrite(waterpump, low);

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

//cloudy days sunny again: turn lights off if light_val exceeds 900. works b/c supplemental lights aren't bright sun:)
if (light_val > 900)
{
digitalwrite (lightswitch, low);
}

//turn off lights if proportion_lit>proportion_to_light, , wait 5 minutes
if (proportion_lit > proportion_to_light)
{
digitalwrite (lightswitch, low);
delay (300000);
}

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

//turn lights on if light_val less 900 , plants have light less desired proportion of time, wait 10 seconds
if (light_val < 900 , proportion_lit < proportion_to_light)
{
digitalwrite(lightswitch, high);
delay(10000);
}

//turn on temp alarm light if temp_val less 850 (approximately 50 degrees fahrenheit)
if (temp_val < 850)
{
digitalwrite(templed, high);
}

}


unfortunately keep getting error messages , i'm not sure how clear them up. error message is:

c:\users\dan\documents\arduino\libraries\datetime\datetime.cpp: in member function 'void datetimeclass::settime(time_t)':
c:\users\dan\documents\arduino\libraries\datetime\datetime.cpp:28: error: 'millis' not declared in scope
c:\users\dan\documents\arduino\libraries\datetime\datetime.cpp: in member function 'time_t datetimeclass::now()':
c:\users\dan\documents\arduino\libraries\datetime\datetime.cpp:43: error: 'millis' not declared in scope

not sure should searching or how go solving function. love skype or facetime figure out. if have solution or point me in right direction i'd grateful.

thanks!

dan

i've solved problem after taking second @ different post, since can't delete original post i'll repost solution worked me:

to make little more clear future users (because had same problem):

first, need downloand , install datetime library. code missing <datetime.h> tag if pull code here: http://archive.makezine.com/18/garduino/

it should read: #include <datetime.h>

next, datetime.cpp file wrong, need open in notepad , change <wiring.h> tag/attribute <arduino.h>

after making 2 changes code should compile correctly.


Arduino Forum > Using Arduino > Programming Questions > Garduino Code Errors


arduino

Comments

Popular posts from this blog

VIDIOC_S_FMT error 16, Device or resource busy - Raspberry Pi Forums

using a laptop skeleton to build a pi laptop - Raspberry Pi Forums

Forum for Joomla? - Joomla! Forum - community, help and support