ccc

Dependencies:   HYT TextLCD mbed

Fork of HYT_example by Ksenia Kondrashova

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers main.cpp Source File

main.cpp

00001 #include "mbed.h"
00002 #include "HYT.h"
00003 #include "TextLCD.h"
00004 TextLCD lcd(p15, p16, p17, p18, p19, p20);
00005 Serial              pc(USBTX, USBRX);
00006 Ticker              timeKeeping;
00007 HYT                 SENSOR (p9, p10); // sda, scl
00008 // HYT sensor polling cycle
00009 void dataUpdate(void)
00010 {
00011     SENSOR.MRCommand();
00012     wait_ms(100);
00013     SENSOR.DFCommand();
00014 }
00015 
00016 void secondsCallback(void) {
00017     pc.printf("Humidity level: %.1f\r\n%", SENSOR.humidity);
00018     pc.printf("Temperature level: %.1f\r\n%", SENSOR.temperature);
00019     pc.printf("-------------------------------\r\n%", SENSOR.temperature);
00020     lcd.locate(1,0);
00021     lcd.printf("Humidity level: %.1f\r\n%", SENSOR.humidity);
00022 }
00023 int main()
00024 {
00025     timeKeeping.attach(&secondsCallback, 1.0f);
00026     while(1) {
00027         dataUpdate();
00028     }
00029 }