array bound is not an integer constant before ','token

const int sensorPin = A0;
const float baselineTemp = 25.55;
void setup()[
Serial.begin(9600); open a serial port
for(int pinNumber = 2; pinNumber<5; pinNumber++)[
pinMode(pinNumber,OUTPUT);
digitalWrite(pinNumber, LOW);
]
]
void loop()[
int sensorVal = analogRead(sensorPin);
Serial.print("Sensor Value: ");
Serial.print(sensorVal);
// convert the ADC reading to voltage
float voltage = (sensorVal/1024.0) * 5.0;
Serial.print(", Volts: ");
Serial.print(voltage);
Serial.print(", degrees C: ");
// convert the voltage to temperature in degrees
float temperature = (voltage - .5) * 100;
serial.println(temperature);
if(temperature < baselineTemp)[
digitalWrite(2, LOW);
digitalWrite(3, LOW);
digitalWrite(4, LOW);
]else if(temperature >= baselineTemp+2 &&
temperature < baselineTemp+4)[
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);
]

Please use code tags.

Read this before posting a programming question

Please edit your post, select the code, and put it between [code ... [/code] tags.

You can do that by hitting the "Code" icon above the posting area. It is the first icon, with the symbol: </>

  void setup()[
    Serial.begin(9600); open a serial port
  for(int pinNumber = 2; pinNumber<5; pinNumber++)[
    pinMode(pinNumber,OUTPUT);
    digitalWrite(pinNumber, LOW);
  ]
]

What are those square brackets? That isn't C.

okay now I've done that and on
Serial.begin(9600); open a serial port
it says the error is 'open' was not declared in this scope

  const int sensorPin = A0;
  const float baselineTemp = 25.55;
  void setup(){
 ----->   Serial.begin(9600); open a serial port    <-----
  for(int pinNumber = 2; pinNumber<5; pinNumber++){
    pinMode(pinNumber,OUTPUT);
    digitalWrite(pinNumber, LOW);
  }
}
void loop(){
  int sensorVal = analogRead(sensorPin);
  Serial.print("Sensor Value: ");
  Serial.print(sensorVal);
// convert the ADC reading to voltage
float voltage = (sensorVal/1024.0) * 5.0;
Serial.print(", Volts: ");
Serial.print(voltage);
Serial.print(", degrees C: ");
// convert the voltage to temperature in degrees
float temperature = (voltage - .5) * 100;
serial.println(temperature);
if(temperature < baselineTemp){
digitalWrite(2, LOW);
digitalWrite(3, LOW);
digitalWrite(4, LOW);
}else if(temperature >= baselineTemp+2 &&
  temperature < baselineTemp+4){
  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);
}

Please post your corrected code. In code tags.

Why are you starting a new thread?

Please do not cross-post. This wastes time and resources a people attempt to answer your question on multiple threads.

Threads merged.

  • Moderator
  const int sensorPin = A0;
  const float baselineTemp = 25.55;
  void setup(){
    Serial.begin(9600); open a serial port
  for(int pinNumber = 2; pinNumber<5; pinNumber++){
    pinMode(pinNumber,OUTPUT);
    digitalWrite(pinNumber, LOW);
  }
}
void loop(){
  int sensorVal = analogRead(sensorPin);
  Serial.print("Sensor Value: ");
  Serial.print(sensorVal);
// convert the ADC reading to voltage
float voltage = (sensorVal/1024.0) * 5.0;
Serial.print(", Volts: ");
Serial.print(voltage);
Serial.print(", degrees C: ");
// convert the voltage to temperature in degrees
float temperature = (voltage - .5) * 100;
serial.println(temperature);
if(temperature < baselineTemp){
digitalWrite(2, LOW);
digitalWrite(3, LOW);
digitalWrite(4, LOW);
}else if(temperature >= baselineTemp+2 &&
  temperature < baselineTemp+4){
  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);
}

the error code reads "'open' was not declared in this scope"

A comment on the end of a line of code, after the semicolon, must be preceded by two slashes, or a begin and end comment.

Serial.begin(9600) ;        //  this is a comment
pinMode( 7, OUTPUT );   /* this is also a comment */

You will save more time by reading a basic text on C/C++ syntax, or an online tutorial, than by writing random nonsense and expecting it to work. It just makes you look like a retard.

  const int sensorPin = A0;
  const float baselineTemp = 25.55;
  void setup(){
    Serial.begin(9600); // open a serial port
  for(int pinNumber = 2; pinNumber<5; pinNumber++){
    pinMode(pinNumber,OUTPUT);
    digitalWrite(pinNumber, LOW);
  }
}
void loop(){
  int sensorVal = analogRead(sensorPin);
  Serial.print("Sensor Value: ");
  Serial.print(sensorVal);
// convert the ADC reading to voltage
float voltage = (sensorVal/1024.0) * 5.0;
Serial.print(", Volts: ");
Serial.print(voltage);
Serial.print(", degrees C: ");
// convert the voltage to temperature in degrees
float temperature = (voltage - .5) * 100;
[color=red]serial.println(temperature);[/color]
if(temperature < baselineTemp){
digitalWrite(2, LOW);
digitalWrite(3, LOW);
digitalWrite(4, LOW);
}else if(temperature >= baselineTemp+2 &&
  temperature < baselineTemp+4){
  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);
}

error now reads "'serial' was not declared in this scope"

[color=red]serial.println(temperature);[/color]

More square brackets?

Hint: capitalization is important in C.

Serial or serial ? Case matters

You need to include arduino.h at the top of your sketch.

wow yeah that worked, its going now, square brackets just now were an attempt to highlight the line where the error was happening, but yeah stupid of me. Thanks a lot!