Below is a sketch that i pulled off the interwebz for an automated watering system.
I get the error compiling message, ind i don't have a clue. ![]()
auto_irrigation_sketch.ino:16:9: error: #include expects "FILENAME" or <FILENAME
#include <Servo.h>
/* Dincer Hepguler 2013
- http://borsaci06.com
- Read analog values from humidity sensor over the serial port
- Command a servo controlled watering system
*/
const int numReadings = 20; //number of readings for smoothing
int readings[numReadings]; // the readings from the analog input
int index = 0; // the index of the current reading
int total = 0; // the running total
//int val = 0; // the average
#include
Servo myservo; //create servo object to control a servo
int sensorPin = A0; //humidity sensor at A0 (analog0)
int pos = 90; //variable to store servo position and set servo to center
int thresholdPin = A1; //threshold pot at A1
int val = analogRead(sensorPin);
int threshold = analogRead(thresholdPin);
void setup() {
Serial.begin(9600);
myservo.attach(9); // attaches the servo on pin 9
// initialize all the readings to 0:
for (int thisReading = 0; thisReading < numReadings; thisReading++)
readings[thisReading] = 0;
}
void loop() {
// subtract the last reading:
total= total - readings[index];
// read from the sensor:
readings[index] = analogRead(sensorPin);
// add the reading to the total:
total= total + readings[index];
// advance to the next position in the array:
index = index + 1;
// if we're at the end of the array...
if (index >= numReadings)
// ...wrap around to the beginning:
index = 0;
int threshold = analogRead(thresholdPin);
val = total / numReadings; // calculate the average
if ( val > threshold) { pos = 180; } //open valve if dry
else { pos = 60 ;} //keep valve closed otherwise
myservo.write(pos); // sets the servo position according to the scaled value
delay(15); // waits for the servo to get there
Serial.print(threshold);
Serial.print(" ");
Serial.print(val);
Serial.print(" ");
Serial.println(pos);
delay(10); // delay in between reads for stability
}