Hi, a month back I tried to make an analog handbrake project for sim racing using an ardiuno pro micro. It didn't work and I had been told that my potentiometer was broken so I bought some new one's which finally arrived.
I plugged just my arduino, without anything connected into my PC via USB. I checked the serial monitor and noticed it's always at 1017-1021, while nothing is connected, if I touch the arduino the values might go lower.
Is this normal or is it the arduino that's broken? I thought it was supposed to be 0 since it shouldn't be reading anything. The only thing physically broken is the A0 connection, it came lose during desoldering my previous connections. So I just use A2 now.
#include <Joystick.h>
void setup()
{pinMode(A2, INPUT_PULLUP);
Joystick.begin();}
void loop()
{
const int pinToButtonMap = A2;
Serial.println(analogRead(pinToButtonMap));
int pot = analogRead(pinToButtonMap);
int mapped = map(pot,0,1023,0,255);
{Joystick.setThrottle(mapped);}
}
checked the serial monitor and noticed it's always at 1017-1021, while nothing is connected, if I touch the arduino the values might go lower.
Yes when nothing is connected to any input on an Arduino, or any other piece of electronics it can read anything. It is known as a floating input.
That will change when you connect your pot. However make sure you connect it correctly or you might damage it. The wiper on the pot goes to the analogue input and the other two connections go to 5V and ground.