demo program for th02 disco l072

Dependencies:   mbed driver_mbed_TH02

Committer:
superphil06
Date:
Mon Jan 25 16:37:24 2021 +0000
Revision:
0:af8ebf004802
demo program for th02

Who changed what in which revision?

UserRevisionLine numberNew contents of line
superphil06 0:af8ebf004802 1 #include "mbed.h"
superphil06 0:af8ebf004802 2 #include "driver_mbed_TH02.h"
superphil06 0:af8ebf004802 3 /*
superphil06 0:af8ebf004802 4 DigitalOut myled1(LED1);
superphil06 0:af8ebf004802 5 DigitalOut myled2(LED2);
superphil06 0:af8ebf004802 6 DigitalOut myled3(LED3);
superphil06 0:af8ebf004802 7 DigitalOut myled4(LED4);
superphil06 0:af8ebf004802 8
superphil06 0:af8ebf004802 9 InterruptIn mybutton(USER_BUTTON);
superphil06 0:af8ebf004802 10 */
superphil06 0:af8ebf004802 11 double tempo = 0.3; // LED blinking delay
superphil06 0:af8ebf004802 12
superphil06 0:af8ebf004802 13 // Change LEDs blinking frequency
superphil06 0:af8ebf004802 14 void change_blinking_frequency() {
superphil06 0:af8ebf004802 15 if (tempo == 0.3) // If leds have low frequency
superphil06 0:af8ebf004802 16 tempo = 0.1; // Set the fast frequency
superphil06 0:af8ebf004802 17 else // If leds have fast frequency
superphil06 0:af8ebf004802 18 tempo = 0.3; // Set the low frequency
superphil06 0:af8ebf004802 19 }
superphil06 0:af8ebf004802 20
superphil06 0:af8ebf004802 21 int main() {
superphil06 0:af8ebf004802 22 float fTemp,fHumid;
superphil06 0:af8ebf004802 23
superphil06 0:af8ebf004802 24
superphil06 0:af8ebf004802 25
superphil06 0:af8ebf004802 26 while(1) {
superphil06 0:af8ebf004802 27 fTemp=myTH02.ReadTemperature();
superphil06 0:af8ebf004802 28 printf("\r\n temp=%f",fTemp);
superphil06 0:af8ebf004802 29 fHumid=myTH02.ReadHumidity();
superphil06 0:af8ebf004802 30 printf("\r\n humid=%f",fHumid);
superphil06 0:af8ebf004802 31 wait(tempo); // wait tempo
superphil06 0:af8ebf004802 32
superphil06 0:af8ebf004802 33 }
superphil06 0:af8ebf004802 34 }