Hey guys, I just finish to re-design and refine my 2 digit multiplex program. The program work, I "fine tune" it and with some modifications could be use for count down or display multidigit system ex: 8 display During testing, the Ardiuno just keep reset ( due to low power/current ) so please use a seperated power line ( +5 V ) if using a 7447 or 7448 chip. If using a CMOS type ( a 4000 series chips ) you can use the 9V ( going into the Ardiuno board ) And of course connect the ground from the Ardiuno to the circuit.
Here the code. I hope it help in some of your designs.
/*
size = 1420
Version 1.6
Here a program to multiplex two seven-seqment LED display.
It will count from 0 to 99.
Tested and Worked
Parts:
1 - 7447 BCD to LED display decoder
1 - 330 ohms resistor network - 14 pins
or
7 - 330 ohms resistor
1 double common anode or cathode 7 segment LED display
or
2 double common anode or cathode 7 segment LED display
2 - PNP - 2N3906 transistor for commun anode
2 - NPN - 2N3906 transistor for commun cathode
2 - 1 k resistor.
When you connect to the Arduino, please use a separated power for
the 7 segment display circuit. And dont forget the ground if I may
quote AWOL :)
Program by Serge J Desjardins <-- techone
Toronto, Ontario, Canada
*/
const int led[6] = {9,10,11,12,7,8};
/*
pin 12 is MSD to pin 9 is LSD
ABCD - pin 12,11,10,9
pin 7 is the unit
pin 8 is the ten's
*/
int pin;
int counting;
int dataone;
int datatwo;
int storage;
int looping;
void setup()
// init the Arduino Pins
{
for (pin =0; pin < 6; pin++ )
{
pinMode (led[pin], OUTPUT);
}
}
void loop()
{
for (counting=0; counting<100; counting++)
// count from 0 to 99
{
BCDconverter();
for (looping=0; looping<200; looping++)
// hold the display for 1 second
{
storage=dataone; // display ten's and place data to be display
displaydigit();
digitalWrite (led[5], LOW); // turn on tens digit
digitalWrite (led[4], HIGH); // turn off the unit digit
/*
if using PNP and commmun anode, need a LOW - 0 signal to
turn the digit on.
if using NPN and commun cathode, need a HIGH - 1 signal to
turn the digit on.
so just simply change LOW to HIGH or HIGH to LOW
*/
delay(5);
/*
the time delay is to prevent "flikering" or strobe effect
the longer the delay, the stonger the strobe effect is.
so keep the time short.
*/
storage=datatwo; // display unit and place data to be display
displaydigit();
digitalWrite (led[5], HIGH); // turn on unit digit
digitalWrite (led[4], LOW); // turn off tens digit
delay(5);
}
}
}
void BCDconverter()
/*
extract the tens and the units numbers
*/
{
dataone=counting/10;
datatwo=counting % 10;
}
void displaydigit()
/*
display the data. ( see my LED display program )
And thank to AWOL for the Loop idea.
*/
{
for (int i = 0; i < 4; i++)
{
digitalWrite (led[i], bitRead(storage,i));
}
}