how to control a servo with temp & humidity
Dependencies: DHT22 Servo mbed
Diff: main.cpp
- Revision:
- 0:671eadfdf703
- Child:
- 1:ccef6d6d9b62
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Tue May 17 16:03:36 2016 +0000 @@ -0,0 +1,32 @@ +#include "mbed.h" +#include "Servo.h" +#include "DHT22.h" + +DigitalOut myled(LED1); +Servo myservo(p4); +DHT22 sensor(p6); +Serial pc(USBTX, USBRX); + +int main() { + + bool status; + pc.printf("\r\nDHT Test program"); + pc.printf("\r\n******************\r\n"); + while (1) { + myled = 1; + status = sensor.sample(); + if (status) { + pc.printf("Temperature is %f C \r\n", sensor.getTemperature()/10.0f); + pc.printf("Humidity is %f \r\n", sensor.getHumidity()/10.0f); + } else { + pc.printf("Error reading sample \r\n"); + } + + myservo = 0.0f; + wait(5); + myservo = 1.0f; + wait(5); + + myled = 0; + } +} \ No newline at end of file