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
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
