Hi. I’m trying to connect my lpc1768 to a temperature sensor lm61 with the aid of a breadboard. I also want to use external leds from breadboard (not ones on mbed) in conjunction with the sensor, in the sense that once a certain temperature range is read by the sensor, one or two of the LEDs should light up . I’ve written code and it looks correct however, it isnt working (probably due to my breadboard connection). Any help would be appreciated. This is code below with some pictures of my connection
#include “mbed.h”
AnalogIn LM61(p15);
DigitalOut red(p21); //Output pin for red led
DigitalOut green(p22); // Output pingreen LED
float Temprt; // average temperature in celsius
float tempF; //average temperature in Fahrenheit
Serial pc (USBTX, USBRX);
int main() {
pc.printf(“LM61 temperature sensor\r\n”);
red=0;//red=0;
green=0; //green=0;
Temprt=((LM61*3.3)-0.600)*10.0; // average temperature value in Celsius (C)
tempF=(9.0*Temprt)/5.0 + 32.0; //average temperature value in fahrenheit (F)
wait(0.3f); //wait a little
pc.printf(“Temperature (in Celsius) is %5.2f \r\n”,Temprt);
wait(0.3f); //wait a little
pc.printf(“Temperature (in Fahrenheit) is %5.2f \r\n”,tempF);
if ( Temprt>=23 && Temprt<=28 ) // If temperature is between 23 and 28 degrees,light green LED on breadboard
{
green=1;
}
else if (Temprt>=29 && Temprt<=35) //If temperature is between 29 and 35 degrees,light red LED on breadboard
{
red=1;
}
}