Hi,
I'm doing the 4th exercise on the Arduino (Genuino) project book, I copied and understood the code from the book, I can't compile it though, I get this error:
Arduino: 1.6.6 (Mac OS X), Board: "Arduino/Genuino Uno"
.../sketch_dec12a.ino: In function 'void loop()':
sketch_dec12a:29: error: 'redSensorPin' was not declared in this scope
redSensorValue = analogRead(redSensorPin);
^
sketch_dec12a:31: error: 'greenSensorValue' was not declared in this scope
greenSensorValue = analogRead(greenSensorPin);
^
sketch_dec12a:31: error: 'greenSensorPin' was not declared in this scope
greenSensorValue = analogRead(greenSensorPin);
^
sketch_dec12a:43: error: 'greenValue' was not declared in this scope
greenValue = greenSensorValue/4;
^
exit status 1
'redSensorPin' was not declared in this scope
This report would have more information with
"Show verbose output during compilation"
enabled in File > Preferences.
this is the code:
const int greenLEDPin = 9;
const int redLEDPin = 10;
const int blueLEDPin = 11;
const int redSendorPin = A0;
const int greensensorPin = A1;
const int blueSensorPin = 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("\t blue: ");
Serial.print(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.print (blueValue);
analogWrite (redLEDPin, redValue);
analogWrite (greenLEDPin, greenValue);
analogWrite (blueLEDPin, blueValue);
}
I can't find the bloody mistake!!