how to control a servo with temp & humidity

Dependencies:   DHT22 Servo mbed

Committer:
nprobably
Date:
Tue May 17 16:03:36 2016 +0000
Revision:
0:671eadfdf703
Child:
1:ccef6d6d9b62
Seeed Archlink Starter Kit - base

Who changed what in which revision?

UserRevisionLine numberNew contents of line
nprobably 0:671eadfdf703 1 #include "mbed.h"
nprobably 0:671eadfdf703 2 #include "Servo.h"
nprobably 0:671eadfdf703 3 #include "DHT22.h"
nprobably 0:671eadfdf703 4
nprobably 0:671eadfdf703 5 DigitalOut myled(LED1);
nprobably 0:671eadfdf703 6 Servo myservo(p4);
nprobably 0:671eadfdf703 7 DHT22 sensor(p6);
nprobably 0:671eadfdf703 8 Serial pc(USBTX, USBRX);
nprobably 0:671eadfdf703 9
nprobably 0:671eadfdf703 10 int main() {
nprobably 0:671eadfdf703 11
nprobably 0:671eadfdf703 12 bool status;
nprobably 0:671eadfdf703 13 pc.printf("\r\nDHT Test program");
nprobably 0:671eadfdf703 14 pc.printf("\r\n******************\r\n");
nprobably 0:671eadfdf703 15 while (1) {
nprobably 0:671eadfdf703 16 myled = 1;
nprobably 0:671eadfdf703 17 status = sensor.sample();
nprobably 0:671eadfdf703 18 if (status) {
nprobably 0:671eadfdf703 19 pc.printf("Temperature is %f C \r\n", sensor.getTemperature()/10.0f);
nprobably 0:671eadfdf703 20 pc.printf("Humidity is %f \r\n", sensor.getHumidity()/10.0f);
nprobably 0:671eadfdf703 21 } else {
nprobably 0:671eadfdf703 22 pc.printf("Error reading sample \r\n");
nprobably 0:671eadfdf703 23 }
nprobably 0:671eadfdf703 24
nprobably 0:671eadfdf703 25 myservo = 0.0f;
nprobably 0:671eadfdf703 26 wait(5);
nprobably 0:671eadfdf703 27 myservo = 1.0f;
nprobably 0:671eadfdf703 28 wait(5);
nprobably 0:671eadfdf703 29
nprobably 0:671eadfdf703 30 myled = 0;
nprobably 0:671eadfdf703 31 }
nprobably 0:671eadfdf703 32 }