Internet of Greens. Mini automated greenhouse, with an internet of sensors.
Dependencies: HC_SR04_Ultrasonic_Library PixelArrayBuffer Servo TSL2561 mbed-rtos mbed
Fork of Final_project by
Diff: support.h
- Revision:
- 1:8e50dcd9884f
- Parent:
- 0:7ebf4813882d
--- a/support.h Tue May 01 13:59:00 2018 +0000 +++ b/support.h Wed May 02 16:50:40 2018 +0000 @@ -38,19 +38,21 @@ //function to water the plant void water_plant() { - watering = true; - watermutex.lock(); - for(float p=0; p<1.5; p += 0.05) { - myservo = p; - wait(0.1); + if (!watering){ + watering = true; + watermutex.lock(); + for(float p=0; p<1.5; p += 0.05) { + myservo = p; + wait(0.1); + } + wait(1); + for(float p=1.5; p>0.0; p -= 0.05) { + myservo = p; + wait(0.1); + } + watermutex.unlock(); + watering = false; } - wait(1); - for(float p=1.5; p>0.0; p -= 0.05) { - myservo = p; - wait(0.1); - } - watermutex.unlock(); - watering = false; } //function to turn on/off neo-pixels