Real Time Lab Program

Dependencies:   C12832_lcd mbed

main.cpp

Committer:
robt
Date:
2015-01-25
Revision:
0:bc00a9403da0

File content as of revision 0:bc00a9403da0:

#include "mbed.h"
#include "C12832_lcd.h"

C12832_LCD lcd;
I2C i2c(p28, p27);
 
const int addr = 0x90;
 
int main() {
    char cmd[2];
    while (1) {
        cmd[0] = 0x01;
        cmd[1] = 0x00;
        i2c.write(addr, cmd, 2);
 
        wait(0.5);
 
        cmd[0] = 0x00;
        i2c.write(addr, cmd, 1);
        i2c.read(addr, cmd, 2);
 
        float tmp = (float((cmd[0]<<8)|cmd[1]) / 256.0);
        lcd.locate(2,5);
        lcd.printf("Temperature  = %.2f degC", tmp);
    }
}