12 years ago.

help me to modify temperature sensor code

there is a code for mbed lpc1768 with the mbed application board, but there is something wrong with my code :( could you help me to correct it

  1. include "mbed.h"
  1. include "LM75B.h"
  1. include "C12832_lcd.h"

PwmOut r (p23);

PwmOut g (p24);

PwmOut b (p25);

C12832_LCD lcd;

LM75B tmp(p28,p27);

int main ()

{

while (1) {

lcd.cls();

lcd.locate(0,3); defined the origin location

lcd.printf("Room Temp. :%.2foC",tmp.read()); output

wait(0.1);

for(float i = 0.0; i < 1.0 ; i += 0.01) {

float p = (((tmp.read()/100)-0.298)*60); defined the color chnge

r = 1.0 - ((p < 1.0) ? 1.0 - p : (p > 2.0) ? p - 2.0 : 0.0);

g = 1.0 - ((p < 1.0) ? p : (p > 2.0) ? 0.0 : 2.0 - p);

b = 1.0 - ((p < 1.0) ? 0.0 : (p > 2.0) ? 3.0 - p : p - 1.0); ;

wait (0.01);

}

}

}

Please use code tags when posting your code. Please tell us why you think something is wrong.

Dave.

posted by David Fletcher 19 Mar 2014
Be the first to answer this question.