1

I have four LED's all connected the exact same way to four pins via four 150OHM resistors. (ignore the sensors, they are doing nothing currently) The code is very simple in the loop:

  digitalWrite(blue1, HIGH);
  digitalWrite(green1, HIGH);

  digitalWrite(blue2, HIGH);
  digitalWrite(green2, HIGH);

Here's a photo of the setup, notice how the LED's all light up differently. They are receiving the following voltages from left to right (2.48, 1.72, 3.02, 2.15):

enter image description here

Why is this happening and how do I get them all to light up the same?

  • Note that, apart from the pinMode issue, blue and green LEDs are likely to have very different forward voltages and quite possibly also different brightness, so balancing their light output is going to be nontrivial anyway. – microtherion Jun 5 '15 at 10:39
3

After trying another Arduino I realized the problem. I did not use pinMode in the setup for all of the pins. Darn.

  • Good point, I've been bitten by this mistake once and it took me quite some time to find out what mistake I had done. – jfpoilpret Jun 5 '15 at 8:40
  • 1
    Yep. By writing to a digital pin that hasn't been specifically set to an output you are actually controlling the internal pullup resistor of the input pin. That allows a small amount of current through, but not much (so a dim glow), and the actual resistor value varies wildly from pin to pin (they don't need to be accurate for pullups), so you get different (dim) brightnesses. – Majenko Jun 5 '15 at 9:50

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.