I bought a flex sensor to my project which is controlling servomotor .
My problem was the flex sensor resistance between "23–31"k ohm. and i cant control the servo with this little range .
what help you suggest and which resistance i use it on the voltage divider that increase the range .
Why can't you control a servo with that range?
Are you trying to directly write the input value to the servo without mapping?
Can you post the code you have and post a copy of your circuit, in CAD or a picture of a hand drawn circuit in jpg, png?
We need to see how you have connected the flex sensor to you controller.
What model controller are you using?
My problem was the flex sensor resistance between "23--31"k ohm. and i cant control the servo with this little range .
To get the most A/D values, use a pull up resistor with a value of the average resistance of the flex sensor.
In this case ~27k.
Write a simple sketch that shows sensor A/D values on the serial monitor.
Map the extreme values of the sensor to the angles of the servo.
This the code i used to read the flex sensor values
int flexsensor1 = 0;
Serial.begin(9600); //serial communication, just for debugging
val1 = analogRead(flexsensor1);
Serial.print("\t flexsensor1 value =\n " );
What are the upper and lower ranges returned for the flex sensor? You will need to map this to the upper and lower settings of the servo.
int servoPin = 9; val1 = analogRead(flexsensor1); val1 = map(val1, 0, 1023, 0, 180); analogWrite(servoPin, val1);
This will map the analog reading which is between 0 and 1023 to the servo output of 0 to 180.
The range on serial monitor between 250-291
i used 10k R .
So in your case:
val1 = map(val1, 250, 291, 0, 180);
Assuming you want to go the 0-180° range.
You can somewhat improve on the accuracy by using a 27k resistor (or 3x10k in series), but not much.
For better resolution get an external ADC such as the ADS1115 which has a 16-bit resolution, so much smaller step size than the 10-bit Arduino ADC.