Pages: [1]   Go Down
Author Topic: shift register to 7 segment  (Read 1082 times)
0 Members and 1 Guest are viewing this topic.
NC,US
Offline Offline
Newbie
*
Karma: 0
Posts: 42
@Weedar_64 #Farmlife
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

Western New York, USA
Offline Offline
Faraday Member
**
Karma: 32
Posts: 4258
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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
Logged

Denmark
Offline Offline
Edison Member
*
Karma: 35
Posts: 1057
Happy Hobbyist
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Try a google search, one of many results

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

Leeds, England
Offline Offline
God Member
*****
Karma: 14
Posts: 590
Quick, chuck it in the bin before the boss finds out...
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

Beginners guide to using the Seeedstudio SIM900 GPRS/GSM Shield

Global Moderator
Boston area, metrowest
Offline Offline
Brattain Member
*****
Karma: 524
Posts: 26473
Author of "Arduino for Teens". Available for Design & Build services. Now with Unlimited Eagle board sizes!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

"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
Logged

Designing & building electrical circuits for over 25 years. Check out the ATMega1284P based Bobuino and other '328P & '1284P creations & offerings at  www.crossroadsfencing.com/BobuinoRev17.
Arduino for Teens available at Amazon.com.

Dallas, TX USA
Offline Offline
Faraday Member
**
Karma: 63
Posts: 2649
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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
Logged

Pages: [1]   Go Up
Jump to: