Secondary Menu

Different Methods of Driving 7 Segment LED Displays With Arduino

I would just like to show a few different methods of connecting 7 segment LED displays to an Arduino or Atmega 328 IC. They are only simple counter codes either automatically counting via the code or incremented / decremented via a pair of push button switches or a potentiometer . I have used 220 Ω resistors in all these circuits but you would be advised to calculate the correct ones required for the particular 7 segment displays that your are using. This will ensure that you do not damage the IO pins of the 328 IC. The constraints to these maximum currents, courtesy ofhttp://www.gammon.com.au/forum/?id=11473 are - - The IO pins have an absolute maximum rating of 40 mA per pin. - Also the following groups of pins should not have more than 100 mA drawn from them * Digital pins 0 to 4 * Digital pins 5 to 1 * Analog pins A0 to A5 - In addition to that, the entire processor chip has a maximum rating of 200 mA current consumption.

The 7 segment LED displays are common cathode and the shift register is a 74HC595. I have included a photo of the 7 segment LED from the front showing the relationship between the pin numbers and the corresponding LED segment that the pin controls.

It is not a responsive site so it is best viewed on a laptop or desktop computer. The Arduino code is nicely formatted by some Javascript that a friend wrote and overall it is just much more aesthetically pleasing content IMO. Thanks for dropping by :)

void show( byte number) { // Use a loop and a bitwise AND to move over each bit that makes up // the seven segment display (from left to right, A => G), and check // to see if it should be on or not for(int j = 0; j <= 7; j++) { byte toWrite = number & (B10000000 >> j);

if(!toWrite) { continue; } // If all bits are 0 then no point writing it to the shift register,so break out and move on to next segment.

shiftIt(toWrite); // Otherwise shift it into the register } } void shiftIt (byte data) { digitalWrite(latchPin, LOW); // Set latchPin LOW while clocking these 8 bits in to the register

// Note that in our case, we need to set pinState to 0 (LOW) for // “On” as the 74HC595 is sinking current when using a common // anode display. If you want to use a common cathode display then // switch this around. if ( data & (1 << k) ) { digitalWrite(dataPin, HIGH); // turn “On” } else { digitalWrite(dataPin, LOW); // turn “Off” } digitalWrite(clockPin, HIGH); // and clock the bit in } digitalWrite(clockPin, LOW); //stop shifting out data digitalWrite(latchPin, HIGH); //set latchPin to high to lock and send data }

Here is another guy using two SR, one for each 7Seg. I am out of touch with Arduino as I am now building quadcopters :) which all began from Arduino actually. My website is not responsive as it is an amateur hand coded site but it looks OK on a desktop or laptop. Looks crappy on a mobile device. I have done a much better version on this Instructable there