Guest User

Untitled

a guest
Mar 29th, 2016
56
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 3.28 KB | None | 0 0
  1. int moistureSensor = A0;                              // the anaolog pin connected to the moisture sensor
  2. int tempSensor = A1;                                  // the anaolog pin connected to the temp sensor
  3. int lightSensor = A2;                                 // the anaolog pin connected to the light sensor
  4.  
  5.  
  6.  
  7. #define CH1 8                                         // Defining the first relay to Digital pin 4
  8. #define LEDgreen 4                                     // Delete this later testing purpose
  9.  
  10.  
  11. unsigned long time1 = 1000;                           // The timings 1s
  12. unsigned long time2 = 5000;                           // The timings Moisturesensor 5s
  13. unsigned long time3 = 10000;                         // The timings Tempsensor 10mins
  14. unsigned long time4 = 20000;                         // The timings LightSensor 10mins
  15. unsigned long time5 = 85000000;                       // The timings Relay OFF pretty much a day
  16. unsigned long time6 = 30000;                          // The timings Relay ON 30s
  17.  
  18. unsigned long time0 = 0;                              // Zero
  19. unsigned long timec = 0;                              // Current Time
  20. void setup()
  21.  
  22. {
  23.     pinMode(moistureSensor, OUTPUT);
  24.     pinMode(tempSensor, OUTPUT);
  25.     pinMode(lightSensor, OUTPUT);
  26.     pinMode(CH1, OUTPUT);
  27.  
  28.     pinMode(LEDgreen, OUTPUT); // DELETE THIS LATE TEST PLEASE IGNORE
  29.  
  30.     Serial.begin(9600);                                    // Turn on the Serial monitor
  31.  
  32.     digitalWrite(CH1, LOW);                                 // Make the Relay off before starting
  33.     delay(2000);                                           // Wait 2 seconds before starting
  34. }
  35.  
  36. unsigned long lastTick = millis();
  37.  
  38. void loop()
  39. {
  40.     int WaterValue = analogRead(moistureSensor);         // Raw data from the Moisture sensor
  41.     int tempValue = analogRead(tempSensor);              // Raw data from the Temperature sensor
  42.     int lightValue = analogRead(lightSensor);            // Raw data from the Light sensor
  43.  
  44.     int TempC = (tempValue);                             // Calucation for degrees celcuis
  45.     int Light = lightValue;                              // A light value
  46.     int Water = WaterValue;                              // The mositure levels
  47.  
  48.  
  49.                                                          //   digitalWrite(CH1, HIGH);                            //Green LED on DELETE THIS LATER TEST PLEASE IGNORE
  50.                                                          //   delay(1000);
  51.                                                          //   digitalWrite(CH1, LOW);                             //Green LED off DELETE THIS LATER TEST PLEASE IGNORE
  52.                                                          //   delay(1000);
  53.  
  54.  
  55.     if(millis() - lastTick >= 5000) {
  56.         Serial.print(Water);
  57.         Serial.println(" ");
  58.  
  59.         lastTick = millis();
  60.  
  61.         //  Serial.print ("Water is ");                          // Prints the word "water is" for the next part line
  62.         //  Serial.print (Water);                                // Prints words low, med, high
  63.         //  Serial.print (" at ");                               // Spacing
  64.         //  Serial.print (TempC);                                // Prints the temp in degrees Celcius
  65.         //  Serial.print (" degrees C ");                        // Prints the words degrees C
  66.         //  Serial.print (Light);                                // Prints whatever comes out the lightsensor
  67.         //  Serial.println (" lumens ");                         // Prints the output lumens
  68.         //  delay(1000);
  69.     }
  70. }
Advertisement
Add Comment
Please, Sign In to add comment