Pages: [1]   Go Down
Author Topic: (SOLUCIONADO)ayuda con el código de garduino  (Read 120 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 2
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

hola muy buenas a todos y gracias por vuestra atención lo primero, me dispongo a crear un proyecto llamado garduino:

http://makezine.com/projects/make-18/garduino-geek-gardening/

el caso es que el código ya lo da el autor y lo único que he echo ha sido pegarlo tal y como el lo pone , pero me da un error que os lo adjunto en un archivo, he probado a descargar la librería y luego volver a intentarlo pero nada y no se que mas probar, estoy estancado y necesito que me echéis un cable, también decoros que soy muy novato en esto de arduino, ahh se me olvidaba aquí os pongo el código por si veis el error:
//include the datetime library, so our garduino can keep track of how long the lights are on
#include

//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 = DateTime.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 = 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 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);
}

}


* Captura de pantalla 2014-08-31 a la(s) 11.10.52.png (61.28 KB, 502x591 - viewed 11 times.)
« Last Edit: September 01, 2014, 06:12:43 am by wuasichu » Logged

Offline Offline
Full Member
***
Karma: 2
Posts: 189
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Ese código está mal. En la primera línea, ponen un include, sin poner el nombre de la librería. Si tiras para arriba en la parte del código de error, verás esto:

Code:
Arduino: 1.5.7 (Windows 7), Board: "Arduino Uno"

Build options changed, rebuilding all

sketch_aug31a.ino:2:10: error: #include expects "FILENAME" or <FILENAME>
sketch_aug31a.ino: In function 'void setup()':
sketch_aug31a.ino:45:14: error: 'DateTime' was not declared in this scope
sketch_aug31a.ino: In function 'void loop()':
sketch_aug31a.ino:92:26: error: 'DateTime' was not declared in this scope

  This report would have more information with
  "Show verbose output during compilation"
  enabled in File > Preferences.

Básicamente, viene a decir que después del include, se espera un nombre de archivo, o sea, la librería correspondiente.

La línea correcta sería:

Code:
#include <DateTime.h>
« Last Edit: August 31, 2014, 06:12:12 am by carmeloco » Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 2
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

muchas gracias, todo arreglado¡¡¡¡¡ smiley-grin smiley-grin smiley-grin smiley-grin smiley-grin smiley-grin
Logged

Offline Offline
Full Member
***
Karma: 2
Posts: 189
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Ok, recuerda incluir en el titulo del primer post "SOLUCIONADO"
 smiley
Logged

Pages: [1]   Go Up
Jump to: