Documentation confusion:

Hi, I'm just starting out, and the I'm getting confused about the definition of constant HIGH on the arduino programming language reference, in the constant section, it states:

"When a pin is configured to OUTPUT with pinMode, and set to HIGH with digitalWrite, the pin is at 5 volts. In this state it can source current, e.g. light an LED that is connected through a series resistor to ground, or to another pin configured as an output, and set to LOW."

I don't understand the last sentence: does it say that you can configure two pins as digital output and set one to HIGH and another to LOW, and connect the two directly? Why is that useful?

One rarely connects two pins directly together; in fact, it can cause over-current problems if you short a HIGH pin to a LOW pin without any resistance in the circuit.

The sentence is just trying to say that a pin set to HIGH can source current and a pin set to LOW can sink it. Keep it under 20 ma per pin either way and you're good.

-br

Yes it does mean that, and no I can't think of any way that is useful offhand. Maybe to loopback test software serial or something.


Rob

Graynomad:
Yes it does mean that, and no I can't think of any way that is useful offhand. Maybe to loopback test software serial or something.

A 2 pin bi-colour LED maybe.

Just think of the pin set to HIGH as + end of battery and pin set to LOW as - end of battery. You don't want to touch these ends together!! But you can put a small light bulb between the two to light it up. As Riva said, there are LEDs that turn on one color if supplied + and - on pins 1 and 2, then turns on another color when supplied - and + on pins 1 and 2. I think Charlieplexing also uses this trick to control lots of LEDs with very few pins.

Turning 1 output high and 1 output low, repeated quickly 64 times, is the basis for a multiplexed display.

Riva:

Graynomad:
Yes it does mean that, and no I can't think of any way that is useful offhand. Maybe to loopback test software serial or something.

A 2 pin bi-colour LED maybe.

Yes, with a bipolar LED:
0) pin1 LOW, pin2 LOW LED off

  1. pin1 HIGH, pin2 LOW LED one colour
  2. pin1 LOW, pin2 HIGH LED other colour
  3. pin1 HIGH, pin2 HIGH LED off

Note, if you have a RED/GREEN LED, then alternate state s1 and 2 about gives YELLOW (or some approximation), changing the duty cycle lets you 'tune' the colour.

David

Or a low current 5vdc single coil latching relay (mine draw about 13ma) wired directly between two output pins as I have done in a few projects.

  1. pin1 LOW, pin2 LOW No current flowing in relay coil, it retains last commanded state
  2. pin1 HIGH, pin2 LOW relay placed in 'set' state
  3. pin1 LOW, pin2 HIGH relay placed in 'reset' state
  4. pin1 HIGH, pin2 HIGH No current flowing in relay coil, it retains last commanded state

Lefty

OK, so apart from Charlieplexing, bi-colour LEDs, latching relays, light bulbs, small peltier junctions, a low-power H-bridge, 1-wire serial comms and loopback testing I can't think of any way that is useful offhand.


Rob

Graynomad:
OK, so apart from Charlieplexing, bi-colour LEDs, latching relays, light bulbs, small peltier junctions, a low-power H-bridge, 1-wire serial comms and loopback testing I can't think of any way that is useful offhand.


Rob

I agree, except for the loopback testing thingee? Wouldn't any kind of logical 'loop back test' require a output pin wired to a input pin so continuity could be tested? Two outputs don't make any kind of loop back test in my book?

Lefty

Two outputs don't make any kind of loop back test in my book?

Not really, one really has to be an input eh :slight_smile:

EDIT: Thinks, doesn't that apply to most of the other examples as well? No it doesn't. Where's my coffee.


Rob

Graynomad:

Two outputs don't make any kind of loop back test in my book?

Not really, one really has to be an input eh :slight_smile:

EDIT: Thinks, doesn't that apply to most of the other examples as well? No it doesn't. Where's my coffee.


Rob

Well who's idea was the loop back thingee anyway? :smiley:

who's idea was the loop back thingee anyway?

No idea, don't look at me. Loopback test? never heard of anything so stupid. How about those Jets eh? Don't mind me, I'm just passing through.


Rob

:smiley:

Coils in stepper motors have the current flowing either way at differnt times. Usually done by switching each end between +v and 0v. Usually with dedicated chip but you could do it straight fom these outputs.

RichardDL:
Coils in stepper motors have the current flowing either way at differnt times. Usually done by switching each end between +v and 0v. Usually with dedicated chip but you could do it straight fom these outputs.

Yea, several years ago I bought a very small stepper that could be driven directly from output pins, it worked and was cute and all, but I never really found a useful project for it and now I would really have to look in the parts bins to even find it again.

Lefty