[SOLVED] How to set bigger value for potentiometer and stable it?

Hi all,

May I know how to set a bigger value and make it stable? This is the potentiometer that im using...

And here is the code:

PotPosition_value = analogRead(PotPin); //Read and save analog value from potentiometer
PotPosition_value = map(analogRead(PotPosition_value), 0, 1023, 1500, 8500); 

Serial.println(PotPosition_value);

I managed to get the max value. however, the value is unstable:

16:50:01.129 -> 7439
16:50:01.213 -> 7282
16:50:01.281 -> 8500

Thanks in advance!

This code is not correct - the second line is doing an analogRead() on an invalid I/O pin

PotPosition_value = analogRead(PotPin); //Read and save analog value from potentiometer
PotPosition_value = map(analogRead(PotPosition_value), 0, 1023, 1500, 8500); //This is for Launch use only

Serial.println(PotPosition_value);

I think it should be

PotPosition_value = analogRead(PotPin); //Read and save analog value from potentiometer
PotPosition_value = map(PotPosition_value, 0, 1023, 1500, 8500); //This is for Launch use only

Serial.println(PotPosition_value);

And it would be easier to debug if you separate the mapped value from the original value - like this

PotPosition_value = analogRead(PotPin); //Read and save analog value from potentiometer
MappedPosition_value = map(PotPosition_value, 0, 1023, 1500, 8500); //This is for Launch use only

Serial.println(PotPosition_value);
Serial.println(MappedPosition_value);

...R

Robin2:
This code is not correct - the second line is doing an analogRead() on an invalid I/O pin

PotPosition_value = analogRead(PotPin); //Read and save analog value from potentiometer

PotPosition_value = map(analogRead(PotPosition_value), 0, 1023, 1500, 8500); //This is for Launch use only

Serial.println(PotPosition_value);



I think it should be


PotPosition_value = analogRead(PotPin); //Read and save analog value from potentiometer
PotPosition_value = map(PotPosition_value, 0, 1023, 1500, 8500); //This is for Launch use only

Serial.println(PotPosition_value);




And it would be easier to debug if you separate the mapped value from the original value - like this


PotPosition_value = analogRead(PotPin); //Read and save analog value from potentiometer
MappedPosition_value = map(PotPosition_value, 0, 1023, 1500, 8500); //This is for Launch use only

Serial.println(PotPosition_value);
Serial.println(MappedPosition_value);




...R

Thank you!! Robin! :slight_smile: