Mbed + Temperature LM19 sensor and i2c Lcd module

 Use MCU LPC 1114 , i2c Lcd module and LM19 temperature sensor.  Connect Vout of Lm19 to dp9. LM19 datasheet 

MCU LPC 1114 , i2c Lcd module and LM19 temperature sensor. 

Code 
#include “mbed.h”
#define lcd_add ((uint8_t) 0x3E<<1)
AnalogIn   voltage(dp9);
I2C i2c(dp5, dp27);
void write_lcd(uint8_t reg_adr, uint8_t val){
    char cmd[2];
    cmd[0] = reg_adr;
    cmd[1] = val;
    i2c.write(lcd_add, cmd, 2); 
    wait_us(50);
}    
int main(void)
{
    i2c.frequency(100000);
//lcd init
   write_lcd(0x00,0b00111000);
   wait(0.01);
   write_lcd(0x00,0b00111001);
   wait(0.01);
   write_lcd(0x00,0b00010100);
   wait(0.01);
   write_lcd(0x00,0b01111101);
   wait(0.01);
   write_lcd(0x00,0b01010110);
   wait(0.01);
   write_lcd(0x00,0b01101100);
   wait(0.01);
   write_lcd(0x00,0b00001100);
   wait(0.01);
   write_lcd(0x00,0b00000001);
   wait(0.01);
   int i=0;
   char buffer[15];
    while (1) {
        float temp= (voltage*3.3)*(-83.30016)+155.93297;//convert to temperature
        sprintf(buffer,”temp=%2.2lf C”,temp);
        for(i=0;i<=strlen(buffer);i++){
            write_lcd(0x41,buffer[i]);
        }
        wait(0.1);
        write_lcd(0x00,0b00000010);
    }
}

 
 

Sponsored Links: