![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
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
Revision 1:8e50dcd9884f, committed 2018-05-02
- Comitter:
- tamechi3
- Date:
- Wed May 02 16:50:40 2018 +0000
- Parent:
- 0:7ebf4813882d
- Commit message:
- mini automated greenhouse
Changed in this revision
main.cpp | Show annotated file Show diff for this revision Revisions of this file |
support.h | Show annotated file Show diff for this revision Revisions of this file |
--- a/main.cpp Tue May 01 13:59:00 2018 +0000 +++ b/main.cpp Wed May 02 16:50:40 2018 +0000 @@ -28,7 +28,7 @@ moisture_level = moisture; if (!watering && moisture_level > 0.3f) water_plant(); - Thread::wait(2000); //SET CORRECT INTERVAL + Thread::wait(86400000); //SET CORRECT INTERVAL } } @@ -56,7 +56,7 @@ switch_lights(); } - Thread::wait(5000); //SET CORRECT INTERVAL + Thread::wait(2000); //SET CORRECT INTERVAL } } @@ -95,8 +95,8 @@ } case '3': { - std::string s = patch::to_string((float)moisture_level); - //std::string s = patch::to_string((float)sensor.lux()); + //std::string s = patch::to_string((float)moisture_level); + std::string s = patch::to_string((float)sensor.lux()); pi.printf("%s",s); break; }
--- 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