Micro blinking multiple LED "OUTPUT"

Hi,

I am starting to use a Micro board after using an Uno. I started with the simple "Blink" sketch with an led on pin 9 and added a second led on pin 11 for giggles. I noticed that both leds are blinking together. I added a new line to set the digitalWrite on 11 to LOW. They still blink together.

I put led's at pins 10 and 12 to check, they do not turn on. I checked continuity on my breadboard at 9 and 11, it is open - no short. I can change the sketch to use 10 and 12 instead of 9 and 11 and they still blink together.

Is this a bad board or am I missing something? Here is the code, pretty basic:

void setup()
{
pinMode(9, OUTPUT);
pinMode(11, OUTPUT);

}

void loop()
{
digitalWrite(11, LOW); //added after both blinking together
digitalWrite(9, HIGH);
delay(1000);
digitalWrite(9, LOW);
delay(1000);
}

Any help is appreciated.

Do you have two leds (each with a resistor) to a pin and ground ?
If you are sure you have connected it right, there might be a shortcut on the board. But that's not for sure yet. Can you make a photo of the board and the leds ? You can attach it to a post using "Additional Option..." below the text field.
The breadboard could have a bad connection (for example the ground) that might cause this.

Sorry about the lack of detail. I am using the negative bar on the breadboard as a bus, the resistor is from bus to the GND pin on the micro. The leds are from the breadboard row at the pin to the bus. I checked for shorts and found none. I will keep checking my connections and the same setup on the Uno.

You have a problem, and you use the breadboard not as you should. That could be a problem.
Do you have wire clips or something like that, to connect the leds without breadboard.
When you use the breadboard, use the 5V and GND rail in a normal way.

I went through and checked the pins:

Here is what I thought I was doing, two LED’s in parallel as you can see in the attached diagram Two_parallel_leds

In fact what I did was two LED’s in series because I did not check. The diagram shows the “What_happened”

I used a multimeter and found an “OUTPUT” pin is not “OFF” as the literature explains. When you set “OUTPUT” the pin is actually shunted to ground. On my Micro board the resistance between ground and the output pin is 25?.

Because of this my series LED’s lit up with the current flowing through the “HIGH” output pin to ground. You can further test this by placing an led with positive at 9 and the negative leg in 11. When 9 goes “HIGH” the led lights up.

The only pins that are truly off are the ones that are not set as output. I don’t know if this is supposed to happen or not.

You are mixing a few thing, and interpreted a few things wrong. :~
Can you forget about these two leds. Let's assume the whole idea did never happen and let's make a fresh start. :stuck_out_tongue:

An unused Arduino pin in floating (somewhere between 0V and 5V).
When an Arduino pin is set as input, it is still floating.

When an Arduino pin is set as output, it becomes 0V (LOW) immediately.
You can set it HIGH or LOW after that as you wish.

Connecting a led to a pin requires always a resistor. If you forgot that, something might be damaged.
The Arduino pin to a resistor of 150 ohm to 1000 ohm, and that to the led. And from the led to ground.
Don't try anything else.
On this page is a drawing (the resistor is 220 ohm) : http://arduino.cc/en/Tutorial/Blink
When you want 2 leds, use two outputs, each with its own resistor and led.

I agree with forgetting the two LED scenario.

What I am finding more interesting is why does the output pin go to ground?

Yes the voltage is zero, but it is a low resistance current path to ground. I have not found any voltage on any of the unused pins on the micro. Through testing I found they are not grounded either, only the ones called output are.

This inadvertent ground path was causing my error to show up. I wonder how many other errors are occurring because of this ground path? Should I be using a diode to make sure it doesn't cause a problem?

(I will make sure I use the proper resistors for each LED, I learned my lesson on that. :blush:)

I'm not sure what the problem is.

Suppose a pin is OUTPUT and LOW. That pin acts as if it is connected to GND.
Suppose a pin a OUTPUT and HIGH. That pin acts as if it is connected to 5V.
When a pin is set to OUTPUT for the first time, the default is LOW.

That's how it is and that is how it should be :stuck_out_tongue:
The Arduino would be useless if the outputs didn't do that.

The problem is that the instructions state the pin is off, which in my parlance “off” means you have an open circuit. A simple example is a light switch. Unless it is a very special application, the switch opens and there is no path from the switch to ground.
By creating a path to GND, you can accidentally back feed your entire circuit.

I know this is an AC example, but look at the time and trouble in the US for polarized plugs to ensure the hot side of the system was positively switched.

Auger_In:
The problem is that the instructions state the pin is off, which in my parlance "off" means you have an open circuit.

Well there is the problem - what instructions are you taking about?

You are quite right. In digital circuits, we talk about "logic zero" or "LOW" which specifically means the line in question is connected to ground. The term for "not connected" is "tri-state" or "open collector". Indeed early logic families, corresponding to NPN transistors, used logic levels of "zero" as connected to ground (by a switched on transistor) or "one" as not connected to ground given that it would usually be pulled up by a resistor to the supply voltage.

This turns out to be a very useful arrangement, and is continued with the provision in the Arduino (Atmel) chips of an internal pull-up function (if you connect a LED between ground and an input with its logic level defined as HIGH, it will glow dimly).

So the term "off", glibly - unthinkingly - written in tutorials and such, is indeed misleading.

Your initial mistake was of course, wiring two LEDs together to one resistor. You should obviously, always be providing a current-limiting resistor for each LED. :smiley: And you should not be wiring LEDs between two outputs without a current-limiting resistor anyway.

Sorry for the long delay. I was traveling and I cannot log-in on my laptop.

I appreciate the explanations. I finally understand and see where I was making false assumptions. I will make sure that I use resistors.

I just finished a small RC truck controlled by the Kama wireless nunchuk to a Micro. Now moving on to a collision avoidance system for it. This stuff is great!