Three Shift Registers with Serial Control Individual Pins w/ memory

Evening guys,

I have been trying to figure this out for the past 2 nights... I give in :~

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

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.

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

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.