Pages: [1]   Go Down
Author Topic: Three Shift Registers with Serial Control Individual Pins w/ memory  (Read 261 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 38
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Evening guys,

I have been trying to figure this out for the past 2 nights... I give in  smiley-confuse

I have a Uno with three 74hc595 connected.  I have them in "serial" using pins 10(RSK), 12(Data) and 13(serial clock).

What I am trying to do is connect 24 relays to the shift registers. I then want to be able to turn each one on and off individually with a all-off command also available.

I would like to use ascii character serial input to do this, e.g. (A turns relay 1 on, a turns relay 1 off, B turns relay 2 on, b turns relay 2 off.....)

Is this possible or am I dreaming.

Thanks ahead of time for any help or direction.

D
Logged

Global Moderator
Boston area, metrowest
Online Online
Brattain Member
*****
Karma: 437
Posts: 23661
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

First of all fix your wiring. MOSI is D11, use that for Data.

74HC595 has got crap for drive current, this might work if you have them driving NPN or N-channel MOSFETS (logic level parts ) to sink current thru the relays.

The control is actually easy.
Code:
void loop(){
if (Serial.available() >0){   // serial data came in?
incomingByte  = Serial.read(); // read it
switch(incomingByte){ // select a pattern to put out
case 'A':
digitalWrite(ssPin, LOW); // make sure shift registers have 0.1uF cap on their Vcc pin.
SPI.transfer(lBxxxxxxxx);  // put in 0, 1 as needed - 1 turns on NPN/N-channel to sink relay coil current
SPI.transfer(Byyyyyyyy);
SPI.transfer(Bzzzzzzzz);
digitalWrite(ssPin, HIGH);
break;

case 'B':
digitalWrite(ssPin, LOW);
SPI.transfer(lBxxxxxxxx);
SPI.transfer(Byyyyyyyy);
SPI.transfer(Bzzzzzzzz);
digitalWrite(ssPin, HIGH);
break;

case 'b':
digitalWrite(ssPin, LOW);
SPI.transfer(lBxxxxxxxx);
SPI.transfer(Byyyyyyyy);
SPI.transfer(Bzzzzzzzz);
digitalWrite(ssPin, HIGH);
break;
:
:
} // end switch
} // end loop
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.

Croatia
Offline Offline
Sr. Member
****
Karma: 11
Posts: 432
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

You might also want to check out this library.
http://bildr.org/2011/08/74hc595-breakout-arduino/

It is extremely straightforward to change one particular pin.
Logged

Pages: [1]   Go Up
Jump to: