Help with driving a 7-seg display using picaxe?

Rio

New Member
Basically, i'm wanting to make a steady hand game.
I was thinking of having a number of 'lives' and would like to be able to write a programme that will count down one for every life lost (everytime the loop touches the wire) say from 5 to 0 and display the amount of lives on a 7-segment display.
I've used MPASM before so i have some idea of what i'm doing but i decided it would make my life easier to do it in picaxe.
The only way i can see from the picaxe manuals to do it is to have 7 outputs and one input and use whether the input is high or low to call and return from sub-routines which make the corresponding number of outputs go high to show the number on the 7-segment display.
Surely there is an easier, more time effective and less tedious way of doing it than this?!
Also, i'd like to be able to encorporate a down-counting time period to it if i could? I'm also planning to have an LED sequence for a 'win' and 'lose' situtation but i can do that myself.
I know it's a little ambitious for what picaxe knowledge i have so any help would be great.:)
 

bgrabowski

Senior Member
The manual show several ways to drive a 7-seg display. A 4511 IC uses 4 output pins and a 4026 uses just 2 outputs.
 

hal9000

Member
I use a 74ls47 to drive single 7-segment displays from 4 outputs, but yes, the picaxe manuals show some ways that use fewer output lines..
 

BCJKiwi

Senior Member
Sounds like you will need quite a few outputs for the 7 seg plus the other "extras" so an I/O expander of some sort is the simplest solution over all.

Currently using 16 port I/O expanders to drive a 7 seg display, a bunch of LEDs etc. Takes a bit of getting your head around and in my experience, well worth the effort.
Theres a code example here for the 28X1 and MCP23016;
http://www.picaxeforum.co.uk/showthread.php?t=8098

Also found that it's simpler and quicker in code and operation to build a list of the bit patterns you need and store them in eeprom for sending out to the i/o expander (or directly to a 7 seg display).
 

gbrusseau

Senior Member
Hal9000 mentioned the 74LS47 IC, a BCD to 7 segment display driver. It uses 4 PICAXE output pins to display the numbers 0 thru 9 and six other characters. I'm with Hal9000 as this is the best way to control a 7 segment display.

See attachment or URL if you don't have Adobe Reader.
web.mit.edu/6.s28/www/datasheets/DM74LS47.pdf
 

Attachments

GreenLeader

Senior Member
Hi
I used a pair of 4026B's to drive 2x7-seg displays, just copying the manual's example. (see sketch attached). Need only two lines - one to reset and one to pulse the 4026B's clock line.

I used this to display a number from 0-99. To display -ve numbers, I used a third PICAXE line to turn on the two decimal points.
Tested it all on breadboard and it worked fine...
 

Attachments

Rio

New Member
The problem is that i only have a pic16F84 that i can programme.
So i'm guessing that i'll have to use 7 outputs and 1 input.
 

Peter M

Senior Member
You can also use a 74ls164 (serial to 8 bit parallel) to display a variety of characters, symbols and numbers using lookup tables to light what ever segments you like with just 2 output pins. one pin for serial data, one pin for clock

If you need more outputs cascade a couple together (16 o/p's with 2 from the picaxe) and use a word variable
You only need an 08m to do this... probaly cost less than your 16f84 and much easier to program
 
Last edited:

eclectic

Moderator
Picaxe solution

If you bought a Picaxe 18X (or better, a 28X1)
and a 4026, then you'd be well on the way to
solving your problems.

e.
 

moxhamj

New Member
I've been studying GreenLeader's circuit and it really is quite a clever solution. With the cascading output I think it might be the minimum number of pins (2). And the code also ends up much smaller than standard 7 segment code - simply set up a for-next loop that counts up to the desired number and toggle the clock inside the loop. That is only going to be 5-6 lines of code and that is significant because other 7 seg solutions tend to eat up a lot of precious code space in 08/08M/14M chips.
 

GreenLeader

Senior Member
I've been studying GreenLeader's circuit and it really is quite a clever solution. With the cascading output I think it might be the minimum number of pins (2). And the code also ends up much smaller than standard 7 segment code - simply set up a for-next loop that counts up to the desired number and toggle the clock inside the loop. That is only going to be 5-6 lines of code and that is significant because other 7 seg solutions tend to eat up a lot of precious code space in 08/08M/14M chips.
Wish it was my idea, but it's just copied straight out of the PICAXE manuals! (as was the code I used to drive it).
 

Rio

New Member
Thanks for the help everyone.
I'm going to try and get my hands on a 4026B chip if i can.
Until then, i'm going to atleast attempt it using a 16F84 as that's all i have for the minute.
Very limited resources i know!
 

SD2100

New Member
i'm going to atleast attempt it using a 16F84 as that's all i have for the minute. Very limited resources i know!
Nothing wrong with the 16F84, th 84 has 13 I/O lines so you could connect the 7 segment display directly to the 84 and still have plenty of spare I/O for the probe, reset button, buzzer etc etc.
 

Rio

New Member
Thanks for all the help everyone. I've made it all and it works fine. I have a timer on it also. Really happy with the way it all turned out :)
 
Top