Unknown problem with Love-o-Meter from projects book

Well I ran through the project just fine, my LED's light up as the sensor gets warmer... However when I go into the serial monitor for some reason it is not printing out the temperature

const int sensorPin = A0;
const float baselineTemp = 20.0;
void setup() {
  // put your setup code here, to run once:
 Serial.begin(9600);
for (int pinNumber = 2; pinNumber<5; pinNumber++){
 pinMode (pinNumber , OUTPUT);
 digitalWrite (pinNumber , LOW);
 } 
}

void loop() {
  // put your main code here, to run repeatedly:
  int sensorVal = analogRead(sensorPin);
  Serial.print("Sensor Value: ");
  Serial.print(sensorVal);
  float voltage = (sensorVal/1024.0)*5.0;// new value represents pins voltage
  Serial.print(" , Volts: ");
  Serial.print(voltage);
  float temperature = (voltage - .5)*100;
  Serial.println(temperature);
    if(temperature<baselineTemp){
      digitalWrite(2,LOW);
      digitalWrite(3,LOW);
      digitalWrite(4,LOW);
    }else if (temperature >=baselineTemp && temperature< baselineTemp+4){
      digitalWrite(2,HIGH);
      digitalWrite(3,LOW);
      digitalWrite(4,LOW);
    }else if (temperature >= baselineTemp +4 && temperature<baselineTemp+6){
      digitalWrite(2,HIGH);
      digitalWrite(3,HIGH);
      digitalWrite(4,LOW);
    }else if (temperature >= baselineTemp +6){
      digitalWrite(2,HIGH);
      digitalWrite(3,HIGH);
      digitalWrite(4,HIGH);
    }
  delay(1);
}

Other than that everything seems to be working fine.
also, on a side note; what does pinNumber++ do?
the book didn't really explain it and I had a hard time finding out on google so far.

sorry if this question has been asked a million times, I'm new to the forums as well as the Arduino and programming in general. Any help will be greatly appreciated, Thank you!

I can't help with your Serial issue.

pinNumber++ increments the value in the variable pinNumber by one.

It's short for

pinNumber =  pinNumber + 1;
OR
pinNumber += 1;

Note:
incrementing pointers this way will increment them by the size of the (base) type (e.g. a pointer to an int will increment the pointer value by sizeof(int) so it points to the next integer.

1 Like

Does it print anything at all on the screen?

You need to work on your code layout. At the beginning you have a lot of white space. Too much , in fact.

Later,youdon'thavenearenough.

Consistency is a good thing.

NOTHING follows a } on the same line, in ANY recognized coding style.

Check the baud that Serial monitor is set to (drop down menu, lower right of serial monitor window). The program is set to 9600 (Serial.begin(9600) in setup()). I tried your code and it compiles and prints to serial monitor just fine.

thank you! you guys are very helpful!