SHT V4 5V UART

Dependencies:   mbed

Fork of SHT_v1 by Stephen McGarry

main.cpp

Committer:
fblanc
Date:
2016-02-23
Revision:
1:0dbbb4802508
Parent:
0:df1c8f2961a1

File content as of revision 1:0dbbb4802508:

// simple test for SHT temp  modules

#include "mbed.h"

#include "SHT.h"
const char VERSION[]="2014_11_14";
Serial pc(USBTX, USBRX); // tx, rx
//SHT sht(PTE2,PTE3,SHT_high); // sclock, data
SHT sht(p19,p20,SHT_high); // sclock, data
DigitalOut led1(LED1);
Ticker flipper;

void flip()
{
  led1=!led1; 
  sht.update(SHT_high);
}

void pc_rx(void)
{
    char c;
    c=pc.getc();
    switch (c) {

        case 'H':
        case 'h':
            pc.printf("Humdity     [ %3.2f %% ]\r\n", sht.get_humidity());
            break;
        case 'T':
        case 't':
            pc.printf("Temperature [ %3.2f C ]\r\n", sht.get_temperature());
            break;
        case 'V':
        case 'v':
            pc.printf("version %s\r\n",VERSION);
            break;

    }


}
int main() {
flipper.attach(&flip, 0.5);
    while (1) {
        if (pc.readable())
            pc_rx();


    }
}