Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- int moistureSensor = A0; // the anaolog pin connected to the moisture sensor
- int tempSensor = A1; // the anaolog pin connected to the temp sensor
- int lightSensor = A2; // the anaolog pin connected to the light sensor
- #define CH1 8 // Defining the first relay to Digital pin 4
- #define LEDgreen 4 // Delete this later testing purpose
- unsigned long time1 = 1000; // The timings 1s
- unsigned long time2 = 5000; // The timings Moisturesensor 5s
- unsigned long time3 = 10000; // The timings Tempsensor 10mins
- unsigned long time4 = 20000; // The timings LightSensor 10mins
- unsigned long time5 = 85000000; // The timings Relay OFF pretty much a day
- unsigned long time6 = 30000; // The timings Relay ON 30s
- unsigned long time0 = 0; // Zero
- unsigned long timec = 0; // Current Time
- void setup()
- {
- pinMode(moistureSensor, OUTPUT);
- pinMode(tempSensor, OUTPUT);
- pinMode(lightSensor, OUTPUT);
- pinMode(CH1, OUTPUT);
- pinMode(LEDgreen, OUTPUT); // DELETE THIS LATE TEST PLEASE IGNORE
- Serial.begin(9600); // Turn on the Serial monitor
- digitalWrite(CH1, LOW); // Make the Relay off before starting
- delay(2000); // Wait 2 seconds before starting
- }
- unsigned long lastTick = millis();
- void loop()
- {
- int WaterValue = analogRead(moistureSensor); // Raw data from the Moisture sensor
- int tempValue = analogRead(tempSensor); // Raw data from the Temperature sensor
- int lightValue = analogRead(lightSensor); // Raw data from the Light sensor
- int TempC = (tempValue); // Calucation for degrees celcuis
- int Light = lightValue; // A light value
- int Water = WaterValue; // The mositure levels
- // digitalWrite(CH1, HIGH); //Green LED on DELETE THIS LATER TEST PLEASE IGNORE
- // delay(1000);
- // digitalWrite(CH1, LOW); //Green LED off DELETE THIS LATER TEST PLEASE IGNORE
- // delay(1000);
- if(millis() - lastTick >= 5000) {
- Serial.print(Water);
- Serial.println(" ");
- lastTick = millis();
- // Serial.print ("Water is "); // Prints the word "water is" for the next part line
- // Serial.print (Water); // Prints words low, med, high
- // Serial.print (" at "); // Spacing
- // Serial.print (TempC); // Prints the temp in degrees Celcius
- // Serial.print (" degrees C "); // Prints the words degrees C
- // Serial.print (Light); // Prints whatever comes out the lightsensor
- // Serial.println (" lumens "); // Prints the output lumens
- // delay(1000);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment