trainning_template

Dependencies:   mbed

Files at this revision

API Documentation at this revision

Comitter:
brainliang
Date:
Tue Dec 01 07:10:01 2020 +0000
Parent:
5:7534fc9248a8
Commit message:
trainning_template

Changed in this revision

main.cpp Show annotated file Show diff for this revision Revisions of this file
sensors.cpp Show annotated file Show diff for this revision Revisions of this file
--- a/main.cpp	Tue Dec 01 05:21:19 2020 +0000
+++ b/main.cpp	Tue Dec 01 07:10:01 2020 +0000
@@ -7,26 +7,24 @@
 #include "sensors.h"
 #include "converters.h"
 
-int gasOK;
-boolean item;
+float temp;
+float humi;
 
+dht11 dht11_PA_0(PA_0);
 Serial Serial_2(PA_2,PA_3);
-YL analog_PC_15(PC_15,PA_0);
-DigitalOut myDigitalOutPC_13(PC_13);
 
 int main() {
 
 
 Serial_2.baud(9600);
 
-item = 0;
 while (true) {
-item = !item;
-myDigitalOutPC_13.write(item);
+if (dht11_PA_0.getdata()) {
+temp = dht11_PA_0.gettemperature();
+humi = dht11_PA_0.gethumidity();
+Serial_2.printf("temp:%.2f\n",_p(temp));
+Serial_2.printf("humi:%.2f\n",_p(humi));
 wait_ms(1000);
-if (analog_PC_15==true) {
-gasOK = analog_PC_15.read();
-Serial_2.printf("gas: %d\n",_p(gasOK));
 }
 }
 
--- a/sensors.cpp	Tue Dec 01 05:21:19 2020 +0000
+++ b/sensors.cpp	Tue Dec 01 07:10:01 2020 +0000
@@ -188,11 +188,13 @@
 //-------
 float dht11::gethumidity()
 {
+    getdata();
     return H;
 }
 //-------
 float dht11::gettemperature()
 {
+    getdata();
     return T;
 }