I got a problem with this code from Arduino Projects Book, a very simple code soryy if is very obvius.
This is the code I wrote:
const int greenLEDpin = 9;
const int redLEDpin = 10;
const int blueLEDpin = 11;
const int redSensorpin = A0;
const int greenSensorpin = A1;
const int blueSensorpin = A2;
int redValue = 0;
int greenValue = 0;
int blueValue = 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.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.print(blueValue);
analogWrite(redLEDpin, redValue);
analogWrite(greenLEDpin, greenValue);
analogWrite(blueLEDpin, blueValue);
}
And here is the error: Arduino:1.7.10 (Windows 8.1), Placa:"Arduino Uno"
LED_tricolor.ino: In function 'void loop()':
LED_tricolor.ino:24:2: error: 'redSensorValue' was not declared in this scope
LED_tricolor.ino:26:2: error: 'greenSensorValue' was not declared in this scope
LED_tricolor.ino:28:2: error: 'blueSensorValue' was not declared in this scope
Someone knows whats happening here? I tried some things like puting the variables before, but nothing... Hope u guys can help me ^^.
Aucun commentaire:
Enregistrer un commentaire