frederic blanc / Mbed 2 deprecated SHTxx2013

Dependencies:   mbed

Fork of SHT_v1 by Stephen McGarry

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers main.cpp Source File

main.cpp

00001 // simple test for SHT temp  modules
00002 
00003 #include "mbed.h"
00004 
00005 #include "SHT.h"
00006 const char VERSION[]="2014_11_14";
00007 Serial pc(USBTX, USBRX); // tx, rx
00008 //SHT sht(PTE2,PTE3,SHT_high); // sclock, data
00009 SHT sht(p19,p20,SHT_high); // sclock, data
00010 DigitalOut led1(LED1);
00011 Ticker flipper;
00012 
00013 void flip()
00014 {
00015   led1=!led1; 
00016   sht.update(SHT_high);
00017 }
00018 
00019 void pc_rx(void)
00020 {
00021     char c;
00022     c=pc.getc();
00023     switch (c) {
00024 
00025         case 'H':
00026         case 'h':
00027             pc.printf("Humdity     [ %3.2f %% ]\r\n", sht.get_humidity());
00028             break;
00029         case 'T':
00030         case 't':
00031             pc.printf("Temperature [ %3.2f C ]\r\n", sht.get_temperature());
00032             break;
00033         case 'V':
00034         case 'v':
00035             pc.printf("version %s\r\n",VERSION);
00036             break;
00037 
00038     }
00039 
00040 
00041 }
00042 int main() {
00043 flipper.attach(&flip, 0.5);
00044     while (1) {
00045         if (pc.readable())
00046             pc_rx();
00047 
00048 
00049     }
00050 }
00051