![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
Final Project for ECE-4180
Dependencies: mbed Servo mbed-rtos 4DGL-uLCD-SE PinDetect
main.cpp
- Committer:
- oscargao
- Date:
- 2020-11-21
- Revision:
- 0:941787ae3c86
- Child:
- 1:5ceaf94b79e4
File content as of revision 0:941787ae3c86:
#include "mbed.h" AnalogIn waterSensor(p20); AnalogIn moistureSensor(p19); AnalogIn lightSensor(p18); Serial pc(USBTX, USBRX); // tx, rx PwmOut speaker(p21); PwmOut led(p22); PwmOut warningLight(LED1); int main() { pc.printf("\rstart printing\n"); int counting = 0; float water = 0.0; float light = 0.0; float moist = 0.0; speaker.period(1.0/2000.0); 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); 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; } wait(1); } }