I'm trying to find some information/advice on how to go about coding to read multiple analog inputs. I'm creating a device in Max and am creating a controller with 4 potentiometers for the parameters on my device, I have got all of the pots to work individually but I'm lost when it comes to coding them all together. I'm using the simple 'AnalogReadSerial' and 'ReadAnalogVoltage' to try and achieve this, but I often get error messages. I am very new to this, I can't seem to find anything online which leads me to believe I am looking for the wrong thing. Any help would be great!
Here's what I've put so far:
// the setup routine runs once when you press reset:
void setup() {
// initialize serial communication at 9600 bits per second:
Serial.begin(9600);
}
// the loop routine runs over and over again forever:
void loop() {
// read the input on analog pin 0:
int sensorValue = analogRead(A0);
Serial.println("A0 Works");
delay(1);
int sensorValue = analogRead(A1);
Serial.println("A1 Works");
delay(1); // delay in between reads for stability
}
The logic behind this is I want to be able to read the pots separately.
This is the error message:
Arduino: 1.8.19 (Mac OS X), Board: "Arduino Uno"
/var/folders/2h/1v85b0t1461gl8qnzhw42bv40000gn/T/arduino_modified_sketch_162508/AnalogReadSerial.ino: In function 'void loop()':
AnalogReadSerial:25:7: error: redeclaration of 'int sensorValue'
int sensorValue = analogRead(A1);
^~~~~~~~~~~
/var/folders/2h/1v85b0t1461gl8qnzhw42bv40000gn/T/arduino_modified_sketch_162508/AnalogReadSerial.ino:22:7: note: 'int sensorValue' previously declared here
int sensorValue = analogRead(A0);
^~~~~~~~~~~
exit status 1
redeclaration of 'int sensorValue'
This report would have more information with
"Show verbose output during compilation"
option enabled in File -> Preferences.