Potentiometer Value Changes When Using PWM

When PWM is used to change the color of an RGB LED, a potentiometer's reading varies considerably.

What can I do to limit the varying potentiometer readings?

I am experienced with software, but pretty new when it comes to electronics. I am working on a project where I have a potentiometer(pot) set up, and its value read in the loop of the sketch. The Arduino sends the pots value over serial when the value is changed by more than 5. This is just an arbitrary number I picked that prevents the value to be constantly sent every loop, as well as the normal float of the reading. This was working as desired until I added a RGB LED to the mix. The LED's color constantly fades from one color to the next. The code for this is based off of this repo: rgb_spectrum. The code has been changed so it uses the the main loop and an interval value that prevents blocking. IE the colors change and the program can still perform other operations without hanging on any loops or delay statements. This is also working as desired. When I added the LED using PWM, the value read from the potentiometer began to vary a considerable amount more no change to the pot physically, or in software. These are two separate pieces of a larger whole, and I don't want them to interact in any way.

The potentiometer is hooked up to the Arduino's 5v, ground, and pin A0 to read the value.
The LED's anodes are hooked up to pins 9, 10, and 11 with a 270 ohm resistor in series to each. The cathode of the LED is hooked to ground.

Additional Info
This problem occurs when the Arduino is powered using a serial cable connected to my desktop computer, and when it is powered using its barrel connector and a 9v 1A power supply. I have attempted many searches for this, but I only find info on how PWM works, or tutorials on how to fade an LED using a potentiometer. Below are the min and max values read from the pot over about a 10 second run, as well as the PWM values of the RGB LED at that time. The voltages were calculated using potValue * (5.0 / 1023.0) I am not sure if this issue is simply because the resistors used for the LED are not large enough, but any additional information on this problem would be appreciated.

Min and Max
Min Value: 239
Min Voltage: 1.17
RED: 138 Green: 117 Blue: 0

Max Value: 405
Max Voltage: 1.98
RED: 244 Green: 0 Blue: 11

Sounds like it might be either:

  • Noise on the Power Line, imparted by the PWM current, through the LEDs.
  • Sagging in the Power Line due to voltage drops caused by the LED current.

The thing to know, in case you don't already, is the ADC [internal to the Arduino's MCU], in it's default mode, uses the 5V line as it's Reference Voltage. If that voltage varies -- and it very well can, if things are not connected properly -- it will effect the ADC conversion value.

But, lacking a schematic, I can't advise you further.

If you haven't already, please read: How To Use This Forum
And: How To Embed An Uploaded Image

It could also be due to ground lift caused by poor layout. We need to see a photograph of your setup as well.