Go Down

### Topic: shift register to 7 segment (Read 1 time)previous topic - next topic

#### trvslamm

##### Feb 28, 2013, 04:36 am
say I want to use 3 output pins from my arduino (clock,data,latch) to drive 2 shift resisters to 2 standard radioshack 7 segment displays. i have an int value i want displayed on the displays. point me in the right direction.

#### floresta

#1
##### Feb 28, 2013, 05:25 am
It's kind of a tossup but my inclination would be to point you toward the 'LEDs and Multiplexing' section although there are several shift register experts that hang around here as well.

See what happens here, and if you don't get any ideas after a while then try the other section of the forum.

Don

#### Erni

#2
##### Feb 28, 2013, 01:41 pm
Try a google search, one of many results

http://arduino.cc/forum/index.php?topic=138482.15

#### dannable

#3
##### Feb 28, 2013, 04:24 pm
In brief - integer division and modulus. Connect each output from the '595 to one of the segments. Put the character designs into an array then you can simply pull the latch low, output digit[n], output digit[m]. Pull the latch high to display.

But watch the total current you can draw from your shift register. Typically this is around 70mA, and each segement of your display will probably draw 20-30 mA.
Beginners guide to using the Seeedstudio SIM900 GPRS/GSM Shield

#4
##### Feb 28, 2013, 04:42 pm
"2 standard radioshack 7 segment displays" Common anode or common cathode?
You just want to display the highByte on one digit and the lowByte on the other?
Otherwise, you need more digits; 0xFFFF (hex) = 65,535 (decimal).

As hinted above, make an array to define your font being displayed:
byte fontArray[] = {
B00111111, // 0 with 1 = segment on
B00000110, // 1  bit 0 = a, 1 = b, 2 = c, 3 = d, 4 = e, 5 = f, 6 = g, 7 = decimal point if used
B01011011, // 2
// etc. up to 9, and A,b,C,d,E,F for hex display
}

segment definitions:
a
f          b
g
e          c
d         DP

then send it  out. I prefer SPI for fast transfers. Be sure to include a 0.1uF (100nF) cap from thre Vcc pin to Gnd.

digitalWrite(ssPin, LOW);
SPI.transfer( fontArray [ highByte(yourInt) ] );  // swap these 2 around if needed
SPI.transfer( fontArray [ lowByte(yourInt) ] );
digitalWrite(ssPin, HIGH);

pin10 ssPin, connects to output register clock pin (RCK) on both shift registers
pin 11 MOSI, connect to serial data in pin on one device, its serial data out pin connects to serial data in on the next device
pin 13 SCK, connects to shift register clock pin (SRCK) on both shift registers
Designing & building electrical circuits for over 25 years.  Screw Shield for Mega/Due/Uno,  Bobuino with ATMega1284P, & other '328P & '1284P creations & offerings at  my website.

#### bperrybap

#5
##### Feb 28, 2013, 05:55 pm

digitalWrite(ssPin, LOW);
SPI.transfer( fontArray [ highByte(yourInt) ] );  // swap these 2 around if needed
SPI.transfer( fontArray [ lowByte(yourInt) ] );
digitalWrite(ssPin, HIGH);

If the value contained in youint is a normal "int" and desired values
to be displayed on the LEDs are decimal, then this will not work.
For example if the value of yourint is 12
then highByte would be 0 and lowByte would be 12 or 0xc
If the desire is have one led show '1' and the other show '2' for this value,
then the value of yourInt must first be converted to BCD before you
grab the hight and low bytes.

--- bill

Go Up

Please enter a valid email to subscribe