Arduino thermometer problem with LEDs

Hello everyone,I've attempted to make a thermometer using an LCD screen and 16 LEDs. My intention is to assign one LED to a range of temperature. So, I made this code and when I try to switch them off at a certain temperature they don't. I just tried with the first red LED starting from above and then I will with the rest.

I used the circuit shown in the picture repeated 16 times and the breadboard with the circuit implemented. What have I done wrong? I appreciate your help.

proyectofinallcd.ino (787 Bytes)

Use CTRL T to format the sketch. Please use code tags. Use the </> icon in the posting menu.

[code] Paste sketch here. [/code]

Tell us what you think is happening here.

 if (temperature > 20.0) {//&& temperature < 47.0) {
  digitalWrite(49, HIGH);
  digitalWrite(47, LOW);


Sorry about the tags, but as you noticed I'm new to the forum.
About the code, I wanted to set those pins one LOW an the other HIGH just to check if one of them switch on and the other off if the temperture is higher than 20.

// include the library code:
#include <LiquidCrystal.h>

LiquidCrystal lcd(27, 26, 25, 24, 23, 22);
int sensorPin = A0;
const float baselineTemp = 20.0;

void setup() {
  for(int pinNumber = 40; pinNumber<50; pinNumber++){
    pinMode(pinNumber, OUTPUT);
    digitalWrite(pinNumber, LOW);
  lcd.begin(16, 2);
  lcd.setCursor(2, 0);

void loop() {
  int SensorVal = analogRead(sensorPin);
  float voltage = (SensorVal / 1024.0) * 5.0;
  float temperature = (voltage - .5) * 100;
  Serial.println(" C");
  lcd.setCursor(5, 1);

  if (temperature > 20.0) {//&& temperature < 47.0) {
    digitalWrite(49, HIGH);
    digitalWrite(47, LOW);


Seems like you have some LEDs working what's not working?


It appears pin 9 on the 2803 is not grounded to your Arduino.


Yeah... it was the pin that wasn't grounded to the Arduino, problem solved. Thank you very much ^^

Thank you for reporting back.