Go Down

Topic: Documentation confusion: (Read 2785 times) previous topic - next topic

cfishy

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:

http://arduino.cc/en/Reference/Constants
"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?

billroy

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

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.

_____
Rob
Rob Gray aka the GRAYnomad www.robgray.com

Riva


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.

liudr

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.

CrossRoads

Turning 1 output high and 1 output low, repeated quickly 64 times, is the basis for a multiplexed display.
Designing & building electrical circuits for over 25 years.  Screw Shield for Mega/Due/Uno,  Bobuino with ATMega1284P, & other '328P & '1284P creations & offerings at  my website.

dpharris



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
Dr. David Harris
OpenLCB Dev Team

retrolefty

#7
Dec 29, 2012, 01:58 am Last Edit: Dec 29, 2012, 02:02 am by retrolefty Reason: 1
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.


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

Lefty

Graynomad

#8
Dec 29, 2012, 02:13 am Last Edit: Dec 29, 2012, 02:49 am by Graynomad Reason: 1
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
Rob Gray aka the GRAYnomad www.robgray.com

CrossRoads

Designing & building electrical circuits for over 25 years.  Screw Shield for Mega/Due/Uno,  Bobuino with ATMega1284P, & other '328P & '1284P creations & offerings at  my website.

retrolefty


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

Graynomad

#11
Dec 29, 2012, 02:48 am Last Edit: Dec 29, 2012, 02:56 am by Graynomad Reason: 1
Quote
Two outputs don't make any kind of loop back test in my book?

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

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

______
Rob
Rob Gray aka the GRAYnomad www.robgray.com

retrolefty


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

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

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?  :D

Graynomad

Quote
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
Rob Gray aka the GRAYnomad www.robgray.com

retrolefty


Go Up