![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
Final Project for ECE-4180
Dependencies: mbed Servo mbed-rtos 4DGL-uLCD-SE PinDetect
Diff: main.cpp
- Revision:
- 1:5ceaf94b79e4
- Parent:
- 0:941787ae3c86
- Child:
- 2:95f72e92b370
--- a/main.cpp Sat Nov 21 00:27:36 2020 +0000 +++ b/main.cpp Sat Nov 21 05:32:38 2020 +0000 @@ -1,4 +1,10 @@ #include "mbed.h" +#include "uLCD_4DGL.h" +#include "PinDetect.h" + +uLCD_4DGL uLCD(p9,p10,p11); // serial tx, serial rx, reset pin; + +PinDetect button(p7,PullDown); AnalogIn waterSensor(p20); AnalogIn moistureSensor(p19); AnalogIn lightSensor(p18); @@ -7,33 +13,38 @@ PwmOut led(p22); PwmOut warningLight(LED1); +int led_flip = 1; + +void Button_Callback (void) { + +} + int main() { - pc.printf("\rstart printing\n"); + uLCD.printf("\n\rstart printing\n"); + wait(1); int counting = 0; float water = 0.0; float light = 0.0; float moist = 0.0; speaker.period(1.0/2000.0); + + button.attach_deasserted(&Button_Callback); + button.setSampleFrequency(); while(1) { water = waterSensor.read(); moist = moistureSensor.read(); light = lightSensor.read(); - pc.printf("%d: ",counting); - pc.printf("%f water\n\r",water); - pc.printf("%f moist\n\r",moist); - pc.printf("%f light\n\r",light); + uLCD.cls(); + uLCD.printf("%d:\n\r",counting); + uLCD.printf("%f water\n\r",water); + uLCD.printf("%f moist\n\r",moist); + uLCD.printf("%f light\n\r",light); counting++; - led.write(1-light); - if (light<0.3){//water>0.4 //mosit<0.3 - speaker = 0.3; - warningLight.write(.5); - } - else - { - speaker = warningLight = 0; - } + if (light<0.1){led.write(1-light);} + else{led = 0;} + wait(1); } }