Need 25 Pin as out put 2 pins for sensor & 23 for Relays

Hi I'm new i need 23 Lights out put for relays pin 2 & 3 I'm using for IR Sensor
Need 23 Pins For relays can anyone help me that code and diagram thanks in Advance

I'm using Arduino Nano

Hello, do yourself a favour and please read How to get the best out of this forum and provide necessary documentation of your ask. At the moment it's clear as mud to me

You have a style of asking as if you would ask "can somebody post the cheat-code for reaching platinum-level"

Which could be answered with a 10 digitnumber and everything is done.
So the short answer is "use IO-expander" - end of message.

Though this does not help very much.
Maybe my guessing is wrong but you seem to be in a hurry to finsish this project.
Well - speeding up finishing your project works this way:

of course you are free to decide to ignore this advice and start waisting time on
trying to hurry down the road. Just to recognise later the hurrying up slows me down
best regards Stefa

I recommend 74hc595 8-bit shift register. 3 of them give you 24 digital output pins at cost of 3 pins on Nano.

HC595 is not a good choice for LEDs or Relays.
TPIC6C595 or TPIC6B595 is better and is controlled the exact same way, and they have outputs rated for 100 and 150mA sink current. The LED anode goes to 5V, the cathode to a current limit resistor, then '595 output; the relay coil goes to 5V or 12V, the other side to the '595 output.
Don't forget 0.1uF (100nF) cap from the 595's VCC pin to Gnd, placed close to the VCC pin.
Shift in a 1 to turn the output on.

4 shift registers provide 32 outputs. Use SPI pins to load them up, or shiftOut on any pins.

digitalWrite (ssPin, LOW);
SPI.transfer(byte1); // ssPin = D10 = latch, SCK = 13 = clock, MOSI = 11 = Serial data in
SPI.transfer(byte2);
SPI.transfer(byte3);
SPI.transfer(byte4);
digitalWrite (ssPin, HIGH); // outputs update on this rising edge
for(;;)
{
  Pt++;
}

:laughing: :laughing:

Arduino is even worse than HC595.

Arduino is plenty fine for driving shift registers to control LEDs and relays.
Easy to wire up, easy to code up.

HC595 is better to drive a LED or matrix than Arduino because 50mA pro channel is more(better) than 20mA. TPIC6B595 is very nice thing but 5 times expensive. and about relay: it exist a relay module with opto. this can be connected directly even to Arduino digital pin.like this one

HC595 is NOT better - with only 70mA ABSOLUTE MAX drive current across ALL 8 outputs in total, it is a terrible driver for anything except other logic devices. In almost every project where they are used the outputs are being overstressed.
5x price difference is also overstated, check pricing at Digikey to confirm.
OP did not ask about Relay modules; I usually drive them with TPIC6B595 or 6C595 outputs directly with just a diode added.

This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.