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.
Revision 6:398753e95e87, committed 2020-12-01
- 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;
}