Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: DHT22 Servo mbed
Fork of Program4_ServoWithTempAndHumidity by
main.cpp
- Committer:
- nprobably
- Date:
- 2016-05-17
- Revision:
- 0:671eadfdf703
- Child:
- 1:ccef6d6d9b62
File content as of revision 0:671eadfdf703:
#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;
}
}
