Connecting Mbed lpc1768 to temperature senor LM61 along with external LEDs

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”);


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
else if (Temprt>=29 && Temprt<=35) //If temperature is between 29 and 35 degrees,light red LED on breadboard



the yellow wire of sensor, which seems to be sensor’s GND, is connected to red line (+) of the breadboard, so the sensor is not grounded.

BR, Jan

Thank you. I am having problems getting the led to light though. How do I get the input temperature from the sensor through the mbed to connect to the leds

When you are not sure or when it is not working, It is usually good to do this step by step.

  1. a program where you test you know and you are able to control a LED.
  2. a program where you are able to read temperature from the sensor - LM61 and TMP36 Analog Temperature Sensors | Mbed
  3. When both points above work, then make new program where you use both parts together. Like your code above.

I also think you have LEDs rotated. According to the picture you have Anode connected to the GND, which is wrong - Light-emitting diode - Wikipedia

BR, Jan