Hello, i have a problem. My arduino leonardo is not reading potentiometer values until i turn it halfway through its range of rotation. Potentiometer is not the problem i have replaced it and it still doesnt work. This is the code that i am using:
#include <Joystick.h>
#define potpin A1
int throttle_ = 0;
int gear = 0;
int some = 0;
int some1= 255;
Joystick_ Joystick(0x12,JOYSTICK_TYPE_JOYSTICK,1,0,true,true,false,true,false,false,true,true,false,false,true);
const bool initAutoSendState = true;
void setup() {
// put your setup code here, to run once:
Joystick.begin();
Serial.begin(9600);
pinMode(9,INPUT_PULLUP);
}
void loop() {
// put your main code here, to run repeatedly:
int variable1 = 461;
int variable2 = 464;
int variable3 = 0;
int variable4 = 0;
throttle_ = analogRead(A5);
if(throttle_ > variable1){
throttle_ = variable2;
}
if(throttle_ < variable3){
throttle_ = variable4;
}
Joystick.setThrottle(throttle_);
Serial.println(throttle_);
}
Connect the ohmmeter leads to the two end pins of the pot and measure the resistance. This is the pot resistance.
Then connect one one lead to one end and one the the middle. Set the pot half way and read the resistance. It should be around half of the reading of the pot resistance.
I already tested it.The pot isnt linear.But the one linear pot that i have it still doesnt change the resistance much at the beginning. I am not using the whole range of the pot.