Go Down

Topic: how many 7 segment LEDs can a arduino run? (Read 1 time) previous topic - next topic

n00b

How many 7 segment LEDs can a arduino run before using a LED Driver IC?

Really want to have 4 counting down 60.00 to 00.00 (MM.SS)

jotux

#1
Aug 12, 2009, 10:30 pm Last Edit: Aug 12, 2009, 11:22 pm by jotux Reason: 1
You can run a 4-digit LED display from the arduino.  I have a 4 digit display from digikey(67-1450-ND) running right now.  You'll need 12 IO.

edit:12 IO, not 16.

n00b


jotux

#3
Aug 12, 2009, 11:11 pm Last Edit: Aug 12, 2009, 11:12 pm by jotux Reason: 1
That display is 4 separate segments.  There are 8 segments per digit, and 4 common cathodes.

You connect the 8 segments and 4 cathodes to 12 IO and drive each digit sequentially.  Here's some code I threw together to display numbers on that particular display.

note: this code isn't all that great, or even all that complete.

Code: [Select]
#include <TimerOne.h> // this is non-standard, download it from the arduino site

const int num_digits = 10;
const byte num_pins   = 8;
const byte num_grounds= 4;
byte grounds[] = {3,2,1,0};                        // g1,g2,g3,g4
byte segments[]  = {9,6,13,12,11,8,7,4};      // A,B,C,D,E,F,G,P

byte num_to_display[]={0,0,0,0};

int led_nums[num_digits][num_pins]=
{
     {1,1,1,1,1,1,0,0},      // 0
     {0,1,1,0,0,0,0,0},      // 1
     {1,1,0,1,1,0,1,0},      // 2
     {1,1,1,1,0,0,1,0},      // 3
     {0,1,1,0,0,1,1,0},      // 4
     {1,0,1,1,0,1,1,0},      // 5
     {1,0,1,1,1,1,1,0},      // 6
     {1,1,1,0,0,0,0,0},      // 7
     {1,1,1,1,1,1,1,0},      // 8
     {1,1,1,1,0,1,1,0},      // 9
};

void setup()
{
     int i;
     for (i = 0;i < num_pins;i++)
     {
           pinMode(segments[i],OUTPUT);
           if (i < num_grounds)
           {
                 pinMode(grounds[i],OUTPUT);
                 digitalWrite(grounds[i],HIGH);
           }
     }
     
     Timer1.initialize(550);
     Timer1.attachInterrupt(updateDisplay);
}

void updateDisplay()
{
     int g,d;
     
     for (g = 0; g < num_grounds;g++)
     {
           for (d = 0;d < num_pins;d++) if(digitalRead(segments[d]) == 1) digitalWrite(segments[d], LOW);      // clear used
           digitalWrite(grounds[g],digitalRead(grounds[g])^1);      // enable digit
           for (d = 0;d < num_pins;d++) digitalWrite(segments[d], (led_nums[num_to_display[g]][d] == 1) ? HIGH : LOW); //write segments
           digitalWrite(grounds[g],HIGH);      // disable digit
     }
}

void loop()
{
     setDigits(1,2,3,4);
}

void setDigits(byte n1, byte n2, byte n3, byte n4)
{
     num_to_display[0] = n1;
     num_to_display[1] = n2;
     num_to_display[2] = n3;
     num_to_display[3] = n4;
}




Blake Arrington

Hey guys, it doesn't look like this was ever answered proper.  I have a similar need:

I need to run 3 separate 8-segment LED displays independently.  Meaning, 1) Stopwatch Timer  2)  Temperature  3)  Calculation

Is three of these overkill? Sparkfun 7-Segment Serial Display
sku: COM-09230

Can the Arduino handle all that?

Thanks!

Blake Arrington

These are what I was asking about.

http://www.sparkfun.com/commerce/product_info.php?products_id=9230

Grumpy_Mike

Yes you can control as many as you want with the arduino. Use the SPI interface and then connect the CSN line of each display to an arduino output to enable it. In that way you can talk to as many devices as you have output pins on the arduino, or even more if you use I/O expanding chips.

Pumbaa

I don't know if size/brightness does matter:
But if you want to show just much numbers, maybe an LCD 2x16 is more suitable?
For the 3x13$ you get a nice LCD. For an LCD you normally need 6 digipins, no matter of coulumn and row of the LCD.

Grumpy_Mike

If you look at this page:-
http://www.andreadrian.de/schach/#Selbstbau_Schachcomputer_SHAH
You will see the schematic has four 7 segment displays multiplexed. The Text is about a chess computer using an arduino and is in German but fortunately the diagram is in schematic an I read that very well.  ;)

Go Up