control a servo with a potentiometer but not with a common ground

Hi I have been trying to control a servo with a 5k potentiometer, it worked really well when I used the Gnd and the 5V of the board, but when I used an external 9V battery to give the servo more power, the potentiometer went kinda crazy and was changing values all the time, it would sometime drop from 1023 to 700 without touching it. So I decided to connect the potentiometer to the Gnd and the 5V of the board, and the motor to the 9V battery, but nothing worked, they apparently need a common ground.

Is there a way to just use the potentiometer as an analogue input and use that input to control a servo that is powered by a different power source?

Sorry for the stupid question, I'm a noob. (Yes I did google the question)

Thanks :slight_smile:

A servo should always be powered from a different supply.
And servo supply negative/ground has to be connected to Arduino ground.
Post a picture of your setup.

sweet yeah that worked I have the ground of the 9V battery connected to the ground of the arduino, and the potentiometer wired up the the arduino (5v and the ground) and the servo wired up to the 9v battery.

would it be dangerous to use more than 9V and have the ground connected to the arduino?

Thanks you are awesome!

Four AA batteries (6volt) might give you more power than a 9volt battery.
A 9volt smoke alarm battery hasn't got the power to run a servo.