0

Clock/Latch pin for Shift out/shift IN
Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.

Clock/Latch pin for Shift out/shift IN

by rizla420 on Mon Sep 14, 2009 11:35 am

Just wanted to get some advice on whether i can consolidate my clock/latch pins for my shift registers.

I currently have 3 daisy chained registers that all utilize 3 pins each:
1 Clock
1 Latch
1 Data

two of the shift registers are using Shift In and one is Shift out.
One set is used to read 24 buttons. Another is used to read data from one of those little boxes that you slide the pins up and down. And the shift out is used to drive 4x 7 segment LED numerical displays



Currently i'm using 9 pins total. Could i free up 6 pins by having them all use the same clock and latch pin? I'm pretty much reading the data/writing the data to them at the same time.

Will this work or will it add some quirks to the way things are functioning right now? I'm just trying to free up as much pin space so i can use a couple shields.

rizla420
 
Posts: 332
Joined: Thu Feb 05, 2009 9:03 pm

Re: Clock/Latch pin for Shift out/shift IN

by adafruit on Mon Sep 14, 2009 12:17 pm

yes you can use the same latch pin!

adafruit
 
Posts: 12151
Joined: Thu Apr 06, 2006 4:21 pm
Location: nyc

Re: Clock/Latch pin for Shift out/shift IN

by rizla420 on Mon Sep 14, 2009 12:59 pm

adafruit wrote:yes you can use the same latch pin!



Can I also use the same Clock pin? Basically in my main loop i'm reading data from the shift in's using dedicated latch/clock/data pins at the beginning of the loop. Then a little farther down, based on the inputs i get, i write some data to the 7 seg LCD's using its own dedicated latch/clock/data pins. Same goes for some LED using a shift out.

SO if i have them all on the same latch, will they all try and either send/read data when the latch gets toggeled? Does the same apply to the clock?

Code: Select all | TOGGLE FULL SIZE
//read button state
digitalWrite(buttons_latchPin,1);
delayMicroseconds(50);
digitalWrite(buttons_latchPin,0);

buttonVal= shiftIn(buttons_dataPin, buttons_clockPin);


code....

//update the LED's i.e turn them on or off based on the buttonVal
digitalWrite(led_latchPin,0);
shiftOut(led_dataPin, led_clockPin, ledDataOut);
digitalWrite(led_latchPin,1);

//update the LCD numberical display accordingly

digitalWrite(LCD_latcPin,0);
shiftOut(LCD_dataPin, LCD_clockPin, LCD_dataOut);
digitalWrite(LCD_latchPin,1);

rizla420
 
Posts: 332
Joined: Thu Feb 05, 2009 9:03 pm

Re: Clock/Latch pin for Shift out/shift IN

by adafruit on Mon Sep 14, 2009 7:26 pm

yes. see the spokepov schematic

adafruit
 
Posts: 12151
Joined: Thu Apr 06, 2006 4:21 pm
Location: nyc

Please be positive and constructive with your questions and comments.