0
\$\begingroup\$

I know this has been answered somewhere but can't find the solution online.

I have an 8ch 5v->120VAC relay controlled by arduino and need help using less digital pins. All channels need to be individually controlled on or off. Space is also an issue as it's on a shield. I've done this in class and reread this link) but am stuck on the coding.

The existing code has 8 variables for each relay's ON/OFF state. These would need to be passed directly to the relay (vs stepped/shifted one at a time like a chase pattern).

Chips on hand: 74HC595
Also have these if needed: (4051,4520,4514,4027,4099)

\$\endgroup\$
2
  • 1
    \$\begingroup\$ It's "fewer pins" not "less pins" and serial to parallel converters sound like the way to go. \$\endgroup\$
    – Andy aka
    Commented Jun 27, 2014 at 18:00
  • 1
    \$\begingroup\$ If you are stuck on the coding, you need to provide your existing code and explain what you are stuck on. For the most part, you can use the ShiftOut example code with barely any modification. \$\endgroup\$
    – Passerby
    Commented Jun 27, 2014 at 23:26

1 Answer 1

1
\$\begingroup\$

Your 74HC595 is probably your best bet. You use 3 pins to control it - a data pin (DS), a clock pin (SHCP), and a latch transfer pin (STCP).

Using the Arduino's shiftOut() function you shift data into the 74HC595 chip, then you toggle the STCP pin to transfer the shifted byte onto the output pins.

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.