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.
main.cpp@2:e443fb501fa4, 2022-06-16 (annotated)
- Committer:
- dantecarrillo
- Date:
- Thu Jun 16 04:35:12 2022 +0000
- Revision:
- 2:e443fb501fa4
- Parent:
- 0:c12c28a0f9e7
DDDH11
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
sam_grove | 0:c12c28a0f9e7 | 1 | |
sam_grove | 0:c12c28a0f9e7 | 2 | #include "mbed.h" |
sam_grove | 0:c12c28a0f9e7 | 3 | #include "DHT.h" |
sam_grove | 0:c12c28a0f9e7 | 4 | |
dantecarrillo | 2:e443fb501fa4 | 5 | DHT sensor(PA_0, DHT11); |
sam_grove | 0:c12c28a0f9e7 | 6 | |
sam_grove | 0:c12c28a0f9e7 | 7 | int main() |
sam_grove | 0:c12c28a0f9e7 | 8 | { |
sam_grove | 0:c12c28a0f9e7 | 9 | int error = 0; |
dantecarrillo | 2:e443fb501fa4 | 10 | float h = 0.0f, c = 0.0f, f = 0.0f, k = 0.0f; |
sam_grove | 0:c12c28a0f9e7 | 11 | |
sam_grove | 0:c12c28a0f9e7 | 12 | while(1) { |
sam_grove | 0:c12c28a0f9e7 | 13 | wait(2.0f); |
sam_grove | 0:c12c28a0f9e7 | 14 | error = sensor.readData(); |
sam_grove | 0:c12c28a0f9e7 | 15 | if (0 == error) { |
sam_grove | 0:c12c28a0f9e7 | 16 | c = sensor.ReadTemperature(CELCIUS); |
sam_grove | 0:c12c28a0f9e7 | 17 | f = sensor.ReadTemperature(FARENHEIT); |
sam_grove | 0:c12c28a0f9e7 | 18 | k = sensor.ReadTemperature(KELVIN); |
sam_grove | 0:c12c28a0f9e7 | 19 | h = sensor.ReadHumidity(); |
dantecarrillo | 2:e443fb501fa4 | 20 | printf("Kelvin: %4.2f, Celcius: %4.2f, Farenheit %4.2f\n", k, c, f); |
dantecarrillo | 2:e443fb501fa4 | 21 | printf("Humedad %4.2f", h); |
sam_grove | 0:c12c28a0f9e7 | 22 | } else { |
sam_grove | 0:c12c28a0f9e7 | 23 | printf("Error: %d\n", error); |
sam_grove | 0:c12c28a0f9e7 | 24 | } |
sam_grove | 0:c12c28a0f9e7 | 25 | } |
sam_grove | 0:c12c28a0f9e7 | 26 | } |