Hi guys, I keep getting the same errors in two different projects
they all seem to be related to this one:
In function ‘void loop()’:
Here are the codes, and bellow the list of errors. Im very very beginner and don’t have a clue on where’s the error. Tks
3rd project Rduino Starter Kit
const int sensorPin = A0;
const float baselineTemp = 20.0;
void setup() {
Serial.begin(9600);
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);
float voltage = (sensorVal/1024.0) * 5;
Serial.print(", Volts: ");
Serial.print(voltage);
Serial.print (", degrees C:");
float temperature = (voltage - .5) = 100;
Serial.println(temperature);
if(temperature < baselineTemp){
digitalWrite(2, HIGH);
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);
}
ERRORS:
Love_Meter.ino: In function ‘void loop()’:
Love_Meter.ino:20:14: error: ‘SensorVal’ was not declared in this scope
Love_Meter.ino:29:36: error: lvalue required as left operand of assignment
Error compiling.
Project 4 Color Mixing Lamp
const int greenLEDPin = 9;
const int redLEDPin = 11;
const int blueLEDPin = 10;
const int redSensor = A0;
const int greensensorPin = A1;
const int clueSensorPin = A2;
int redValue = 0;
int greenValue = 0;
int blueValue = 0;
int redSensorValue = 0;
int greenSensorValue = 0;
int bluesensorValue = 0;
void setup() {
Serial.begin(9600);
pinMode(greenLEDPin, OUTPUT);
pinMode(redLEDPin, OUTPUT);
pinMode(blueLEDPin, OUTPUT);
}
void loop(){
redsensorValue = analogRead(redSensorPin);
delay(5);
greenSensorValue = analogRead(greenSensorPin);
delay(5)
blueSensorValue = analogRead(blueSensorPin);
Serial.print("Raw Sensor Values \t Red: “);
Serial.print(redSensorValue);
Serial.print(”|t Green: “);
Serial.print(greenSensorValue):
Serial.print(”| Blue ");
Serial.println(blueSensorValue);
redValue = redSensorValue/4;
greenValue = greenSensorValue/4;
blueValue = blueSensorValue/4;
Serial.print("Mapped Sensor Values |t Red: “);
Serial.print(redValue);
Serial.print(”\t Green: “);
Serial.print(greenValue);
Serial.print(”\t Blue: ");
Serial.println(blueValue):
analogWrite(redLEDPin, redValue);
analogWrite(greenLEDPin, greenValue);
analogWrite(blueLEDPin, blueValue);
}
ERRORS:
ColorMixing_sketch_feb17a.ino: In function ‘void loop()’:
ColorMixing_sketch_feb17a.ino:29:3: error: ‘redsensorValue’ was not declared in this scope
ColorMixing_sketch_feb17a.ino:29:31: error: ‘redSensorPin’ was not declared in this scope
ColorMixing_sketch_feb17a.ino:31:33: error: ‘greenSensorPin’ was not declared in this scope
ColorMixing_sketch_feb17a.ino:33:3: error: expected ‘;’ before ‘blueSensorValue’
ColorMixing_sketch_feb17a.ino:38:33: error: expected ‘;’ before ‘:’ token
ColorMixing_sketch_feb17a.ino:40:18: error: ‘blueSensorValue’ was not declared in this scope
ColorMixing_sketch_feb17a.ino:51:28: error: expected ‘;’ before ‘:’ token
Error compiling.