I have been working on a little project for an amplifier.
I am using an Arduino UNO and want to control 6 potentiometers however I keep having issues as the potentiometers either don't read, read incorrectly and read correctly.
The potentiometer connected to A0 works fine and has no issues however the ones in A1 and A2 seem to just fine tune the initial A0 value.
The ones after A2 do not work all together.
These have all been wired up the same but with the wire changing each time for the Analogue read.
I am unsure of what I am doing wrong here.
I have followed tutorials on YouTube however even when copying the tutorials exactly it still has issues.
I am currently at work now but will upload my code once I get back home.
The analogue inputs all use the same comparator in the chip so need settling time between reading of different pins. A common technique is to read the value twice and discard the first reading
These have all been wired up the same but with the wire changing each time for the Analogue read.
What are you talking about? The potentiometers are NOT supposed to be plugged and unplugged at random, which your sentence suggests that you are doing.
UKHeliBob:
Please post your code and a wiring diagram
The analogue inputs all use the same comparator in the chip so need settling time between reading of different pins. A common technique is to read the value twice and discard the first reading
Do you mean uploading the code the arduino or posting/updating the results?
MorganS meant for to read the comment that UKHeliBob made, that you seem to have not read when he posted it.
void loop()
{
analogRead(analogInPin0); // Read and throw away the value
Serial.print("0"(analogRead(analogInPin0)));
analogRead(analogInPin1); // Read and throw away the value
Serial.print("1"(analogRead(analogInPin1)));
analogRead(analogInPin2); // Read and throw away the value
Serial.print("2"(analogRead(analogInPin2)));
analogRead(analogInPin3); // Read and throw away the value
Serial.print("3"(analogRead(analogInPin3)));
analogRead(analogInPin4); // Read and throw away the value
Serial.print("4"(analogRead(analogInPin4)));
delay(100);
}
/Users/john/Documents/Arduino/sketch_apr28a/sketch_apr28a.ino: In function 'void loop()':
sketch_apr28a:15:44: error: expression cannot be used as a function
Serial.print("0"(analogRead(analogInPin0)));
^
Your code won't compile. "0"(analogRead(analogInPin0) makes no sense at all.
I have re-Worked the code so it now displays in the monitor.
I am however running into an issue where it should be displaying 0's for everything but the A0 which Says "this is working". Do you know of a way to fix this issue?
I am only using 1 Pot at the moment and that is plugged in to A0.
I would like to view all the results independently.
Here is my current code.
void setup(){
Serial.begin(9600);
}
void loop(){
int sensorValue0 = analogRead(A0);
Serial.println(sensorValue0);
Serial.print("this is working ");
int sensorValue1 = analogRead(A1);
Serial.println(sensorValue1);
Serial.print("eighty ");
int sensorValue2 = analogRead(A2);
Serial.println(sensorValue2);
Serial.print("Ben ");
int sensorValue3 = analogRead(A3);
Serial.println(sensorValue3);
Serial.print("Kack ");
int sensorValue4 = analogRead(A4);
Serial.println(sensorValue4);
Serial.print("slack ");
}