love o meter starting project

I need help with the love o meter project. I wrote the program according to the guide but when I connect it it doesnt work and I dont know what is wrong can somebody tell me what to correct.
I am using an arduino uno and programing with a windows pc
when I connect the arduino and open the serial monitor data starts to appear as it is supposed to, but the leds dont turn on
thanks

ps: my leds are connected to pins 2 to 6 and the sensor to a0

const int sensorPin=A0;
const float baselineTemp= 20.0;
void setup (){
  Serial. begin (9600);
  
  for (int x=2; x<7;x++){
    pinMode (x,OUTPUT);
    digitalWrite (x,LOW);
  }
}
void loop (){
  
  int sensorVal=analogRead(sensorPin);
  Serial.print(sensorVal);
  Serial.print("ADC,");
  float voltage=(sensorVal/1024.0)*5.0;
  Serial.print(voltage);
  Serial.print ("Volts,");
  float temperature=(voltage-.5)*100;
  Serial.print (temperature);
  Serial.println ("degrees,");
  if (temperature<baselineTemp){
    digitalWrite (2,LOW);
    digitalWrite (3,LOW);
    digitalWrite (4,LOW);
    digitalWrite (5,LOW);
    digitalWrite (6,LOW);
  }
  else if(temperature>=baselineTemp+2 && temperature>baselineTemp){
    digitalWrite (2,HIGH);
    digitalWrite (3,LOW);
    digitalWrite (4,LOW);
    digitalWrite (5,LOW);
    digitalWrite (6,LOW);
  }
  else if (temperature>=baselineTemp+4 && temperature> baselineTemp){
    digitalWrite (2,HIGH);
    digitalWrite (3,HIGH);
    digitalWrite (4,LOW);
    digitalWrite (5,LOW);
    digitalWrite (6,LOW);
  }
  else if (temperature>=baselineTemp+6 && temperature>baselineTemp){
    digitalWrite (2,HIGH);
    digitalWrite (3,HIGH);
    digitalWrite (4,HIGH);
    digitalWrite (5,LOW);
    digitalWrite (6,LOW);
  }
  else if (temperature>=baselineTemp+8 && temperature>baselineTemp){
    digitalWrite (2,HIGH);
    digitalWrite (3,HIGH);
    digitalWrite (4,HIGH);
    digitalWrite (5,HIGH);
    digitalWrite (6,LOW);
  }
  else if (temperature>=baselineTemp+10 && temperature>baselineTemp){
    digitalWrite (2,HIGH);
    digitalWrite (3,HIGH);
    digitalWrite (4,HIGH);
    digitalWrite (5,HIGH);
    digitalWrite (6,HIGH);
  }
}

Moderator edit:
</mark> <mark>[code]</mark> <mark>

</mark> <mark>[/code]</mark> <mark>
tags added.

Something does not look right.

ps: my leds are connected to pins 2 to 6 and the sensor to a0
.
.
.
for (int x=1; x<5;x++){ // pins 1 - 4
.
.
.
digitalWrite (1,LOW);
digitalWrite (2,LOW);
digitalWrite (3,LOW);
digitalWrite (4,LOW);
digitalWrite (5,LOW);

what?

First question.

Why are you using pin 1 (don't)

ok iw ould use pin 2…
but it still doesnt work

Your LEDs are on pins 2 - 6. You set pinMode for pins 1 - 4. You toggle pins 1 - 5.

Make up your mind.

What do you get in the serial monitor when you run it?

No cross posting, just update your original post.

Threads merged.

Hi, I think its time for a picture of your project and a CAD or picture of a hand drawn circuit diagram.
This way we can check to see if your input and output circuits are configured correctly.

Hope to help…Tom… :slight_smile:

Here’s your problem. Your IF statements are garbage.

else if(temperature >= baselineTemp+2 && temperature > baselineTemp){

Use case statements, like so.

switch( int( temperature ) )
  {
  case 0 ... 19:
    digitalWrite (2,LOW);
    digitalWrite (3,LOW);
    digitalWrite (4,LOW);
    digitalWrite (5,LOW);
    digitalWrite (6,LOW);
    break;

  case 20 ... 22: // not really need to do it like this, its a little much, but I like consistency
    digitalWrite (2,HIGH);
    digitalWrite (3,LOW);
    digitalWrite (4,LOW);
    digitalWrite (5,LOW);
    digitalWrite (6,LOW);
    break;

  case 23 ... 24:
    digitalWrite (2,HIGH);
    digitalWrite (3,HIGH);
    digitalWrite (4,LOW);
    digitalWrite (5,LOW);
    digitalWrite (6,LOW);
    break;

  case 25 ... 26:
    digitalWrite (2,HIGH);
    digitalWrite (3,HIGH);
    digitalWrite (4,HIGH);
    digitalWrite (5,LOW);
    digitalWrite (6,LOW);
    break;

  case 27 ... 28:
    digitalWrite (2,HIGH);
    digitalWrite (3,HIGH);
    digitalWrite (4,HIGH);
    digitalWrite (5,HIGH);
    digitalWrite (6,LOW);
    break;

  case 29 ... 500:
    digitalWrite (2,HIGH);
    digitalWrite (3,HIGH);
    digitalWrite (4,HIGH);
    digitalWrite (5,HIGH);
    digitalWrite (6,HIGH);
    break;
  }

Well that might be part of it yeah. I did it like this...

  digitalWrite(2, (temperature > baselineTemp) ? HIGH : LOW);
  digitalWrite(3, (temperature > baselineTemp + 2) ? HIGH : LOW);
  digitalWrite(4, (temperature > baselineTemp + 4) ? HIGH : LOW);
  digitalWrite(5, (temperature > baselineTemp + 6) ? HIGH : LOW);
  digitalWrite(6, (temperature > baselineTemp + 8) ? HIGH : LOW);
  digitalWrite(7, (temperature > baselineTemp + 10) ? HIGH : LOW);

Basically the same thing as this, for each pin...

  if (temperature > baselineTemp) {
    digitalWrite(2, HIGH);
  } else {
    digitalWrite(2, LOW);
  }

Each pin comes on at a higher temp than the previous one.