Offline
Jr. Member
Karma: 0
Posts: 70
|
 |
« on: February 01, 2013, 09:30:04 pm » |
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
Brattain Member
Karma: 249
Posts: 16556
Available for Design & Build services
|
 |
« Reply #1 on: February 01, 2013, 09:45:55 pm » |
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
|
|
|
|
|
Offline
Jr. Member
Karma: 0
Posts: 70
|
 |
« Reply #2 on: February 01, 2013, 09:55:05 pm » |
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
Brattain Member
Karma: 249
Posts: 16556
Available for Design & Build services
|
 |
« Reply #3 on: February 02, 2013, 12:09:00 am » |
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
|
|
|
|
|
universe
Offline
Sr. Member
Karma: 0
Posts: 258
I'm enjoying my Life
|
 |
« Reply #4 on: February 02, 2013, 01:20:46 am » |
|
|
|
|
|
Logged
|
|
|
|
|
Global Moderator
Boston area, metrowest
Offline
Brattain Member
Karma: 249
Posts: 16556
Available for Design & Build services
|
 |
« Reply #5 on: February 02, 2013, 01:25:17 am » |
Oh, that is such a kludge of software!
|
|
|
|
|
Logged
|
|
|
|
|
universe
Offline
Sr. Member
Karma: 0
Posts: 258
I'm enjoying my Life
|
 |
« Reply #6 on: February 02, 2013, 01:27:34 am » |
Oh, that is such a kludge of software!
what do you mean with kludge?
|
|
|
|
|
Logged
|
|
|
|
|
Global Moderator
Boston area, metrowest
Offline
Brattain Member
Karma: 249
Posts: 16556
Available for Design & Build services
|
 |
« Reply #7 on: February 02, 2013, 01:37:03 am » |
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);
|
|
|
|
|
Logged
|
|
|
|
|
Offline
Jr. Member
Karma: 0
Posts: 70
|
 |
« Reply #8 on: February 06, 2013, 10:42:58 am » |
i want to display two digit numbers like 99
can i do this with a single shift register?
|
|
|
|
|
Logged
|
|
|
|
|
UK
Offline
Tesla Member
Karma: 89
Posts: 6396
-
|
 |
« Reply #9 on: February 06, 2013, 11:33:21 am » |
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
|
|
|
|
|
Global Moderator
Boston area, metrowest
Offline
Brattain Member
Karma: 249
Posts: 16556
Available for Design & Build services
|
 |
« Reply #10 on: February 06, 2013, 01:33:01 pm » |
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
|
|
|
|
|
Offline
Jr. Member
Karma: 0
Posts: 70
|
 |
« Reply #11 on: February 07, 2013, 08:39:20 am » |
can you give me a rough sketch of the ckt for a 2 digit display using a single 74ls595
|
|
|
|
|
Logged
|
|
|
|
|
|