Why does my analog reading change when LEDs turn on/off?

This is my first post, my searches didn't find a similar issue on the forum. I am a rank beginner with Arduino, electronics and programming, that said here goes...

I have a very simple circuit setup to learn how a few things work: pushbuttons, LEDs, a pot, digital and analog pins.

  • I have 2 pushbuttons, on pins 4 & 5, going through 100? resistors, then through the pushbuttons, then to gnd. (my goal is to reverse the logic and use built-in pull-up resistors, but I'm just starting out)
  • I have a red and yellow LED, each connected with 330? resistors to gnd.
  • I have a 10k? pot connected to 5V and gnd, with the wiper connected to A4.
  • I have the 5V and gnd tied to the rails of my breadboard.
  • It is all powered by USB for this experiment.

In my code I read the pot on A4 every few seconds as opposed to each time through the loop (e.g. a 'long' for a counter variable, reading every time it gets to 100000). I have the buttons acting as independent "toggles" (push-on, push-off) to turn on/off each of the LEDs. I added serial output to see the analog value being read from the pot.

It seems for some reason, that I didn't expect, turning on or off the LEDs changes the analog value being read. If I have the pot at 0 (fully clockwise in this case), and I turn on either LED, the analog value goes up to about 30, both LEDs on and it goes up to about 60. The contribution is less at higher pot values (e.g. each LED only adds about 20 when around 800).

I am assuming I've accidentally created some multi-resistor circuit when the LEDs get turned on.

Is there something obvious that I've done wrong that is causing the analog value to fluctuate? Is there some equally simple way to avoid it?

I can post my code and fritzing if those would help, but I suspect I'm just missing some very basic principle here.

Thanks for any insights.


I think you are seeing "ground bounce" or "Ground movement" due to the LED currents flowing through your breadboard and wires.

Temporarily connect the ground side of an LED circuit with a separate wire to a ground pin on the Arduino board. Does the Analog change go away or greatly reduce??

It may help to draw a diagram of how all the "common ground" things are connected and which share ground wires.

Let us know what you see..

Wow, Terry, great call. I added a jumper from gnd rail right next to one of the LED resistors, and took it to a second gnd socket on the Arduino, and the issue went away. Then I pulled and re-seated the jumpers on 5V and gnd between the breadboard and the Arduino, and presto, all is good. Maybe just slightly oxidized connections that re-seating cleaned up?

Now the pot cycles from 0 to 1023 with no issues, irrespective of LED on/off states.

I would never have expected that. Thank you very much.

Now I can move ahead to the next challenge and try reversing the logic and removing the resistors on my pushbuttons.

OK! Every one of these is a learning experience...

Lotsa stuff you may find useful on the http://ArduinoInfo.Info WIKI

OH: Seattle?? I just got back from Seattle (Pitching Arduino to Librarians who want to put Maker Spaces in LIBRARIES). Great food. Great Beer. Lotsa waterfronts.

Thank you. Yet another good looking resource for those of us starting from the beginning, and feeling like we're drinking from a fire hose!

I think the fascinating thing about Arduino is it seems like such a great launching pad... if you've got an idea for something, there is probably a way to do it with Arduino and a little learning. I'm on my way.