Starter Project
First Milestone
Second Milestone
My project is the self watering and light garden, the garden will get watered based on the time of day. For my second milestone I finished the relay. I learned how to assemble a water pump and connect them together in a relay. I also learned how a relay works, there are many different sides to the relay. One major setback I encountered was that the lights broke during the shipping so the lights had to be reordered. Also the original project used to much voltage so, a new relay also had to be ordered.
Third Milestone
Final Milstone
Final Code:
int moistureSensor = A0;
int lightSensor = A1;
int tempSensor = A2;
int moisture_val;
int light_val;
int temp_val;
int relay=2;
int relaySmall=7;
int ground= 11;
int ground2 = 9;
int ground3= 4;
int light= 8;
void setup() {
Serial.begin(9600); //open serial port
pinMode(relaySmall,OUTPUT);
pinMode(relay, OUTPUT);
pinMode(ground, OUTPUT);
pinMode(ground2, OUTPUT);
pinMode(ground3, OUTPUT);
digitalWrite(ground, LOW);
digitalWrite(ground2, LOW);
digitalWrite(ground3, LOW);
}
void loop() {
moisture_val = analogRead(moistureSensor); // read the value from the moisture sensor
Serial.print(“moisture sensor reads “);
Serial.println( moisture_val );
if (moisture_val < 500){
digitalWrite(relaySmall, HIGH);
Serial.println(“turning on pump”);
}
if (moisture_val > 100)
digitalWrite(relaySmall, LOW); {
Serial.println(“turning off pump”);
}
light_val = analogRead(lightSensor); // read the value from the photosensor
Serial.print(“light sensor reads “);
Serial.println( light_val );
if (light_val <600){
digitalWrite(relay, HIGH);
Serial.println(“turning on lights”);
}
if (light_val > 550){
digitalWrite(relay, LOW);
Serial.println(“turning off lights”);
}
temp_val = analogRead(tempSensor);
Serial.print(“temp sensor reads “);
Serial.println( temp_val );
if (temp_val < 380)
{
digitalWrite (8, HIGH);
Serial.println(“turning on low-temperature LED”);
}
if (temp_val > 380)
{
digitalWrite (8, LOW);
Serial.println(“turning off low-temperature LED”);
}
delay(1000);
}