Offline
Newbie
Karma: 0
Posts: 2
|
 |
« on: December 28, 2012, 05:48:32 am » |
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?
|
|
|
|
|
Logged
|
|
|
|
|
0
Offline
God Member
Karma: 37
Posts: 974
Get Bitlash: http://bitlash.net
|
 |
« Reply #1 on: December 28, 2012, 06:15:46 am » |
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
|
|
|
|
|
Logged
|
|
|
|
|
nr Bundaberg, Australia
Offline
Tesla Member
Karma: 71
Posts: 6830
Scattered showers my arse -- Noah, 2348BC.
|
 |
« Reply #2 on: December 28, 2012, 06:21:19 am » |
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
|
|
|
|
|
Logged
|
|
|
|
|
Norfolk UK
Offline
Edison Member
Karma: 23
Posts: 1320
|
 |
« Reply #3 on: December 28, 2012, 07:25:48 am » |
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.
|
|
|
|
|
Logged
|
|
|
|
|
Central MN, USA
Offline
Faraday Member
Karma: 35
Posts: 5930
Phi_prompt, phi_interfaces, phi-2 shields, phi-panels
|
 |
« Reply #4 on: December 28, 2012, 11:24:18 am » |
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.
|
|
|
|
|
Logged
|
|
|
|
|
Global Moderator
Boston area, metrowest
Offline
Brattain Member
Karma: 248
Posts: 16535
Available for Design & Build services
|
 |
« Reply #5 on: December 28, 2012, 11:52:20 am » |
Turning 1 output high and 1 output low, repeated quickly 64 times, is the basis for a multiplexed display.
|
|
|
|
|
Logged
|
|
|
|
|
0
Offline
Newbie
Karma: 0
Posts: 48
Arduino rocks / OpenLCB rocks
|
 |
« Reply #6 on: December 28, 2012, 07:31:03 pm » |
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
|
|
|
|
|
Logged
|
Dr. David Harris OpenLCB Dev Team
|
|
|
|
Left Coast, CA (USA)
Offline
Brattain Member
Karma: 279
Posts: 15316
Measurement changes behavior
|
 |
« Reply #7 on: December 28, 2012, 07:58:32 pm » |
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
|
|
|
|
« Last Edit: December 28, 2012, 08:02:38 pm by retrolefty »
|
Logged
|
|
|
|
|
nr Bundaberg, Australia
Offline
Tesla Member
Karma: 71
Posts: 6830
Scattered showers my arse -- Noah, 2348BC.
|
 |
« Reply #8 on: December 28, 2012, 08:13:32 pm » |
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
|
|
|
|
« Last Edit: December 28, 2012, 08:49:25 pm by Graynomad »
|
Logged
|
|
|
|
|
Global Moderator
Boston area, metrowest
Offline
Brattain Member
Karma: 248
Posts: 16535
Available for Design & Build services
|
 |
« Reply #9 on: December 28, 2012, 08:16:59 pm » |
|
|
|
|
|
Logged
|
|
|
|
|
Left Coast, CA (USA)
Offline
Brattain Member
Karma: 279
Posts: 15316
Measurement changes behavior
|
 |
« Reply #10 on: December 28, 2012, 08:23:35 pm » |
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
|
|
|
|
|
Logged
|
|
|
|
|
nr Bundaberg, Australia
Offline
Tesla Member
Karma: 71
Posts: 6830
Scattered showers my arse -- Noah, 2348BC.
|
 |
« Reply #11 on: December 28, 2012, 08:48:54 pm » |
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
|
|
|
|
« Last Edit: December 28, 2012, 08:56:46 pm by Graynomad »
|
Logged
|
|
|
|
|
Left Coast, CA (USA)
Offline
Brattain Member
Karma: 279
Posts: 15316
Measurement changes behavior
|
 |
« Reply #12 on: December 28, 2012, 09:00:33 pm » |
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? 
|
|
|
|
|
Logged
|
|
|
|
|
nr Bundaberg, Australia
Offline
Tesla Member
Karma: 71
Posts: 6830
Scattered showers my arse -- Noah, 2348BC.
|
 |
« Reply #13 on: December 28, 2012, 09:41:44 pm » |
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
|
|
|
|
|
Logged
|
|
|
|
|
Left Coast, CA (USA)
Offline
Brattain Member
Karma: 279
Posts: 15316
Measurement changes behavior
|
 |
« Reply #14 on: December 28, 2012, 10:12:53 pm » |
|
|
|
|
|
Logged
|
|
|
|
|
|