Real Time Lab Program

Dependencies:   C12832_lcd mbed

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers main.cpp Source File

main.cpp

00001 #include "mbed.h"
00002 #include "C12832_lcd.h"
00003 
00004 C12832_LCD lcd;
00005 I2C i2c(p28, p27);
00006  
00007 const int addr = 0x90;
00008  
00009 int main() {
00010     char cmd[2];
00011     while (1) {
00012         cmd[0] = 0x01;
00013         cmd[1] = 0x00;
00014         i2c.write(addr, cmd, 2);
00015  
00016         wait(0.5);
00017  
00018         cmd[0] = 0x00;
00019         i2c.write(addr, cmd, 1);
00020         i2c.read(addr, cmd, 2);
00021  
00022         float tmp = (float((cmd[0]<<8)|cmd[1]) / 256.0);
00023         lcd.locate(2,5);
00024         lcd.printf("Temperature  = %.2f degC", tmp);
00025     }
00026 }