Shift register

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 ?

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.

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 ?

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.

I think it is all you need: How to Drive 4 Seven-Segments using IC 74HC595 | KinectDuino

Oh, that is such a kludge of software!

CrossRoads:
Oh, that is such a kludge of software!

what do you mean with kludge?

This whole kludge here:

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:

    digitalWrite(latchPin, LOW);
    shiftOut(dataPin, clockPin, LSBFIRST, fontArray[j]);      
    digitalWrite(latchPin, HIGH);

i want to display two digit numbers like 99

can i do this with a single shift register?

pranoy:
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.

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.

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