![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
final
Dependencies: mbed Servo NeoMatrix mbed-rtos 4DGL-uLCD-SE PinDetect PololuLedStrip
main.cpp
- Committer:
- oscargao
- Date:
- 2020-11-21
- Revision:
- 1:5ceaf94b79e4
- Parent:
- 0:941787ae3c86
- Child:
- 2:95f72e92b370
File content as of revision 1:5ceaf94b79e4:
#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); Serial pc(USBTX, USBRX); // tx, rx PwmOut speaker(p21); PwmOut led(p22); PwmOut warningLight(LED1); int led_flip = 1; void Button_Callback (void) { } int main() { 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(); 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++; if (light<0.1){led.write(1-light);} else{led = 0;} wait(1); } }