arduino using digital pins as grounds?

2,107 views
Skip to first unread message

Shawn McCombs

unread,
Mar 11, 2012, 11:21:33 PM3/11/12
to i3 Detroit Public
So I have a 7 segment led display. I've tested it, and it has two pins
that take +volts and the other 8 take ground to light it up so I think
the right term is common anode.

The question is, if I am trying to make it work with less parts as
possible. What's the best way to do it?
Transistors that connect the display segments to ground, and +volts
going to base from the arduino?
Is there a way to make a pin turn to ground, instead of 5 volts?

I've been looking at a couple of sites, but I just don't understand
how a common anode display can work without transistors, or something.

http://allaboutee.com/2011/02/05/arduino-7-segment-display-tutorial/

I've also been seeing something about shift registers working to
ground stuff, but I don't understand the difference in the code that
says ground it instead of put +volts to it.

Thanks everyone.

Eric Merrill

unread,
Mar 11, 2012, 11:24:42 PM3/11/12
to i3detroi...@googlegroups.com

Yeah, low output is ground.

--
You received this message because you are subscribed to the Google Groups "i3 Detroit Public" group.
To post to this group, send email to i3detroi...@googlegroups.com.
To unsubscribe from this group, send email to i3detroit-publ...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/i3detroit-public?hl=en.

Shawn McCombs

unread,
Mar 11, 2012, 11:31:34 PM3/11/12
to i3 Detroit Public
... really? O.o that for some reason just makes no since to me... lol
but ok I'll try it.

By the way this is what I am trying to remake. It's for PICs so I'm
trying to make it with AVRs and Arduino so it's easier. I'm also
adding a few more features so it's more functional.

http://hackaday.com/2012/02/12/puncher-tracks-your-freelancing-hours-time-spent-in-tsa-patdowns/

Shawn McCombs

unread,
Mar 11, 2012, 11:51:06 PM3/11/12
to i3 Detroit Public
This site says: http://tronixstuff.wordpress.com/2010/07/07/getting-started-with-arduino-chapter-twelve/

one catch (always a catch…) is that is was common-anode. This means
that current starts from the power supply, through the common anode
pin for the particular digit, then the LED segment, the LED’s
individual cathode pin, through the current-limiting resistor and then
to ground. With the current flowing in the opposite direction via a
common anode, we can’t just hook the display up to our 74HC595 shift
register.

Therefore, we will need the shift register to control switches to
allow the current to flow through each segment, just like we have done
previously controlling the cathodes of a common cathode display (see
example 12.1). So to control the digits of this new display, we will
need twelve switches (eight for the segments of the digit, and four to
control the anodes). That would mean twelve BC548 transistors and 10k
ohm resistors, and a lot of mess.

Instead we will now use the 74HC4066 quad bilateral switch IC.




So this is what I was thinking.. so is it that the Arduino can have a
pin on LOW and that means ground, but if you use the shift register
then it doesn't work that way?

Roger S

unread,
Mar 12, 2012, 12:37:16 AM3/12/12
to i3detroi...@googlegroups.com
Why are you using a shift register? If you have 14 digital output
pins, they can each sink up to 20 mA, so you should be able to drive
the display segments directly. You might use a shift register if you
don't have enough output pins, but that complicates things I think.
Then you have to clock the bits out.
To recap: the path would be: power supply +V to common anode to
resistor to digital pin on Arduino and through that to ground.

Aaron Dubin

unread,
Mar 12, 2012, 7:44:37 AM3/12/12
to i3detroi...@googlegroups.com
If you're using an arduino and have pins to spare (if all you're interfacing with is 1 7 segment and a button I'd imagine you will have plenty) as Roger says, you should be able to wire them direct to the AVR and be good to go. Source the +V off the rail with a current limiting resistor, then change the digital pin from high to low. According to this article:
http://arduino.cc/playground/Main/ArduinoPinCurrentLimitations
the arduino can actually sink twice as much current as it can source, making this actually a better choice, at least as best my newbie brain can figure. Can PWM if you're worried about current too.

Roger S

unread,
Mar 12, 2012, 12:09:05 PM3/12/12
to i3detroi...@googlegroups.com

Don't current limit at the anode!  It will get dimmer as you light up more segments!

Nathaniel Bezanson

unread,
Mar 12, 2012, 1:22:47 PM3/12/12
to i3detroi...@googlegroups.com
On Sunday, March 11, 2012 11:21:33 PM UTC-4, Shawn McCombs wrote:
Is there a way to make a pin turn to ground, instead of 5 volts?
 
Microcontroller I/O pins typically have 3 states:
 
HIGH - A pull-up transistor in the uC connects the pin directly to Vcc. To cause this state, you set the appropriate bit in the port control register to "output" and then write a "1" to the pin itself.
 
LOW - A pull-down transistor in the uC connnects the pin directly to Gnd. To cause this state, you set the appropriate bit in the port control register to "output" and then write a "0" to the pin itself.
 
HI-Z - Nothing in the uC is attempting to pull the pin high or low, so it just floats at whatever level the rest of the circuit pushes it to. To cause this state, set the appropriate bit in the port control register to "input". (On some chips, I think it's also necessary to write a "0" to the pin itself.) Performing a read from the pin itself, while in the input state, will return a 1 or a 0 depending on what voltage level the pin is floating at. Most chips set all I/O pins to this state at power-on (that is, the port control register initializes to "all-inputs"), until the program makes them do something else. The name is from the letter Z's use to denote "impedance"; in this state, the pin has a high impedance.
 
If you want to stretch your brain a bit, read up on Charlieplexing; it's a fascinating technique that uses all three states.
 
AVRs, and perhaps other microcontrollers, also implement a fourth state: INPUT WITH WEAK PULL-UP. In this state, a *different* pull-up transistor in the uC connects the pin to Vcc with a high-value resistor in series. Because switches are usually read by pulling them up with a resistor, then letting the switch yank the line to ground, building this pull-up into the chip saves on external parts-count. I'm not quite certain how to cause this state; I think it might involve setting the pin to "input" and then writing a "1" to it. Corrections welcome!
 
Shift registers will call themselves "tri-state" if they implement a Hi-Z state. But because this means each pin has more than one bit worth of state information, this means the shift register (or whatever other component is implementing it) must also have an extra register of bits to control the state. (Think of it like alpha-channel transparency in video.)
 
Incidentally, Aaron is right, in that the AVR (as well as most other chips) can sink more current than it can source. Which is to say, if you want to direct-drive a bunch of LEDs, you could wire the cathodes to ground and use the uC to bring the anodes high, but you'd only light a handful before the chip was over its specified current. Alternately, you could wire the anodes to Vcc and use the uC to bring the cathodes down, and you'd be able to control more LEDs without overloading anything.
 
In all cases, RTFM before putting a lot of load on the chip! Even if you don't smoke anything, heavily loading the I/O pins can tax the Vcc and Gnd nets, which may throw your analog reference off, mess with reset or brownout detection logic, and other pains.

Mark Pirkola

unread,
Mar 12, 2012, 2:03:29 PM3/12/12
to i3detroi...@googlegroups.com
I wouldn't attach any divice directly to a processor. In your case I would use an octal latch chip.


 

Roger S

unread,
Mar 12, 2012, 4:52:27 PM3/12/12
to i3detroi...@googlegroups.com

To set pull up on, set port/pin to input (DDR) then write a logical 1 to the port/pin.  There's also a fuse bit you can program to disable all pull ups.  Make sure it's set to default which allows pull ups.

Reply all
Reply to author
Forward
0 new messages