Pages: [1]   Go Down
Author Topic: Shift register  (Read 844 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Jr. Member
**
Karma: 0
Posts: 76
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi guys,

          I have a number that needs to be shifted out
        I have 3 pins remaining(pins 1,2 & 13) in arduino uno.
         can i use this TX and RX pins to drive a shift register like 74HC595 ?
         how can i convert my decimal no to binary and shift it out through a pin like say pin 1 ?
Logged

Global Moderator
Boston area, metrowest
Offline Offline
Brattain Member
*****
Karma: 518
Posts: 26378
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

Yes, if you are not planning on any serial comm's.
Use shiftout and define the pins you want to use.
If you use
shiftout(dataPin, clockPin, MSBFIRST, data_to_send);
it will go out as binary.  128D = 0x80, 255D = 0xFF, etc. No conversion needed.
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.

Offline Offline
Jr. Member
**
Karma: 0
Posts: 76
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

for (int j = 15; j ==0; j--)
{
   
    digitalWrite(latchPin, LOW);
    shiftOut(dataPin, clockPin, LSBFIRST, j);   
   
    digitalWrite(latchPin, HIGH);
    delay(1000);
  }


will this code give the output as decreasing from 15 to 0 with a delay of 1 second between each digits at a seven segment display ?
Logged

Global Moderator
Boston area, metrowest
Offline Offline
Brattain Member
*****
Karma: 518
Posts: 26378
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

No, you need to define a font array that maps the segments to turn on for each digit.

fontArray[] = [B00111111, B00000110, ...,}; // for 0,1,2 with bits representing DP, g,f,e,d,c,b,a and 1 = segment that is in

     a
f         b
     g
e        c
     d      DP

then
shiftOut(dataPin, clockPin, LSBFIRST, fontArray[j]);

and segments connected to the shift register accordingly.
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.

universe
Offline Offline
Sr. Member
****
Karma: 0
Posts: 258
I'm enjoying my Life
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

I think it is all you need: http://zugiduino.wordpress.com/2012/07/11/how-to-drive-4-seven-segments-using-ic-74hc595/
Logged

Global Moderator
Boston area, metrowest
Offline Offline
Brattain Member
*****
Karma: 518
Posts: 26378
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

Oh, that is such a kludge of software!
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.

universe
Offline Offline
Sr. Member
****
Karma: 0
Posts: 258
I'm enjoying my Life
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Oh, that is such a kludge of software!
what do you mean with kludge?
Logged

Global Moderator
Boston area, metrowest
Offline Offline
Brattain Member
*****
Karma: 518
Posts: 26378
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

This whole kludge here:
Code:
void show(int numberToDisplay,int fromLine) 

113 { 

114 if (numberToDisplay < 10) 

115 { 

116 g_registerArray [3] = g_digits [0]; 

117 g_registerArray [2] = g_digits [0]; 

118 g_registerArray [1] = g_digits [0]; 

119 g_registerArray [0] = g_digits [numberToDisplay]; 

120 } 

121 else if (numberToDisplay < 100) 

122 { 

123 g_registerArray [3] = g_digits [0]; 

124 g_registerArray [2] = g_digits [0]; 

125 g_registerArray [1] = g_digits [numberToDisplay / 10]; 

126 g_registerArray [0] = g_digits [numberToDisplay % 10]; 

127 } 

128 else if (numberToDisplay < 1000) 

129 { 

130 g_registerArray [3] = g_digits [0]; 

131 g_registerArray [2] = g_digits [numberToDisplay / 100]; 

132 g_registerArray [1] = g_digits [(numberToDisplay % 100) / 10]; 

133 g_registerArray [0] = g_digits [numberToDisplay % 10]; 

134 } 

135 else

136 { 

137 g_registerArray [3] = g_digits [numberToDisplay / 1000]; 

138 g_registerArray [2] = g_digits [(numberToDisplay % 1000) / 100]; 

139 g_registerArray [1] = g_digits [(numberToDisplay % 100) / 10]; 

140 g_registerArray [0] = g_digits [numberToDisplay % 10]; 

141 } 

142 sendSerialData (g_registers, g_registerArray, fromLine); 

143 } 

Only need this:
Code:
    digitalWrite(latchPin, LOW);
    shiftOut(dataPin, clockPin, LSBFIRST, fontArray[j]);     
    digitalWrite(latchPin, HIGH);
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.

Offline Offline
Jr. Member
**
Karma: 0
Posts: 76
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

i want to display two digit numbers like 99

can i do this with a single shift register?
Logged

UK
Offline Offline
Shannon Member
****
Karma: 222
Posts: 12534
-
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

i want to display two digit numbers like 99

can i do this with a single shift register?


To answer that you need to know the number of inputs needed to drive your display (probably at least seven per character, meaning at least fourteen in total) and the number of outputs provided by the shift register you're using. Obviously the number of outputs available from the shift register must be greater than or equal to the number of inputs needed by the display.
Logged

I only provide help via the forum - please do not contact me for private consultancy.

Global Moderator
Boston area, metrowest
Offline Offline
Brattain Member
*****
Karma: 518
Posts: 26378
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

Quote
i want to display two digit numbers like 99

can i do this with a single shift register?
Yes, but you will need 2 transistors to enable one digit or the other.
Switch back & forth between them, persistance of vision will make them both appear on.
That is how 4-digit display work also.  All the segments are wire in parallel, each digit having a unique common anode or common cathode pin; only one common pin is enabled at a time to turn on 1 digit (set of segments) at a time.
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.

Offline Offline
Jr. Member
**
Karma: 0
Posts: 76
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

can you give me a rough sketch of the ckt for a 2 digit display using a single 74ls595
Logged

Pages: [1]   Go Up
Jump to: