Project - Multiputs - Controlling 8 inputs using a 74HC595 and 4 wires


For your multiputs project, I am just waiting for you to start selling it.


I believe that one could use the MaxO module instead of the 75HC595 chip. I wouldn’t even begin to know sell this. I really do these to promote the product line, learn electronics, and make educational projects for others.

I’m happy that it has any interest at all!

@ wbsimms - I am monitoring 3 doors and may add another. I am using these switches - paired with the magnets out of hard drives. The switch and magnet need to be within 2 to 3 inches to make the switch close. I am using a cerbuino and have Justin’s Bluetooth to communicate with a tablet inside the house so the ability to read 4 switches using 4 inputs is pretty attractive.

@ bill_wyo Yeah, you’ll definitely need a 74HC595 for this. I get mine from Addicore. They’re new on the scene but very supportive. They add these little pin cards which are very handy and have a great site.

You can also use the MaxO module.

Both solutions need diodes on the outputs though. You can get a dead short otherwise. I learned that the hard way.

Let me know how it goes and if there’s anything I can do to help.

Are you thinking of polling the four reed switches, say every 500ms, to check the status of the door? Your consideration of using the '595 suggests that this is acceptable, or do you want an interrupt to fire when the status of the door changes? In either case I don’t think you need to use the '595 IC.

The sockets ( with and ‘!’ next to them are interrupt enabled. Using an extender ( ) for each reed switch and connecting it to pin 3 would allow each switch to raise an interrupt.

If you are happy polling then a single extended into a ‘Y’ socket would allow you to poll each pin for the status of the port. I’d also recommend connecting each input pin to Vcc through a 10K resistor and then using the reed switch to connect the input pin to Gnd. This would cause the input to go low then the switch is closed.

Hope that helps.

Something like this for each input (up to seven using a Y socket).

@ Jason Would this need each door to use an interrupt pin?

@ wbsimms - If you want an interrupt raised and know which door it’s from then yes each door would need to use it’s own interrupt pin. Since each socket only includes a single interrupt GPIO (!GPIO on ), you’d need to use one socket, plus extender, for each reed switch. If you are happy polling, stepping through each door in your code and checking it, then a single ‘Y’ socket using pins 3, 4, 5 & 6, each with a circuit like the one I posted, would work just fine too.

The '595 method only polls when the interrupt is triggered. It only uses one interrupt pin. This method let you monitor many switches with only 4 pins while allowing identification of the specific switch. Sorry if this information was lost in the original post.

@ wbsimms - Are you using the '595 to supply the voltage to each switch in turn and then connect each reed switch to the same input? Is that why you included diodes? You still have to drive (poll) the switches I guess? With each switch individually connected to a Gadgeteer pin you program could be idle (or doing something else) and the interrupt would fire when a switch state changed.

You could also consider using a '597 or '165 to read in the status of a number of switches and achieve the same goal I think.

That’s the fun of electronics; there’s always a ton of ways to achieve the same goal…

@ Jason The polling only happens in the interrupt handler.

I’ll look a those other chips. I’m still learning what’s available and always appreciate any suggestions.

void interruptInput_Interrupt(InterruptInput sender, bool value)
    int check = 1;
    for (int i = 0; i <= 7; i++) 
        if (interruptInput.Read()) 
            onPins = onPins + 1; 
        onPins = onPins << 1; 
        check = check << 1; 
    onPins = 0; 

@ Jason - I intended to poll the switches but an interrupt would be very nice. Two of my 3 Gadgeteer sockets are occupied, Bluetooth and temp/humidity, and it appears that as the sockets are used some of the pins on the Arduino style headers become inaccessible. The limited number of pins made the use of four pins to read 8 switches pretty attractive. The discussion in the last several posts has made me rethink what I am doing and I can now see how to simplify the cerbuino part and also the Bluetooth communication with the tablet. The back and forth between you and wbsimms has been helpful.

@ Bill_Wyo - You’re welcome. Keep us updated on how you get on.

@ wbsimms - After looking into this a bit more I am a little puzzled. You are reading 8 buttons which sounds like parallel in serial out. Wouldn’t this be the 74HC165?

@ wbsimms - I may have figured out what you are doing. The allon variable creates outputs which you have wired through buttons. This is how the interrupt works. If you had done this with a parallel in serial out chip you would have required 5 pins but by using the 595 you only need 4 pins. Still not sure about the diodes you mentioned but I will keep looking.

Would it help if I put together a video of how it’s wired together?

I probably could have used another chip… but I don’t know about most of them yet… still learning. :slight_smile:

The diodes on the '595 outputs is to solve a dead short potential which can happen if you’re holding a button down, allowing current to flow, while the polling happens.

This guys has as great video explaining how this is done.

Whew… saves me from making a video.

1 Like

@ wbsimms - The video really explained it for me. Thanks. Do you think the c# code is fast enough to have 4 595s linked like the MaxO module? It seems like a MaxI module would be useful.

@ bill_wyo It’s very fast in my example with 8 buttons. I could never “beat” the timer. Check out the video. Like with anything, good testing is important.

A MaxI module would be useful. I bet it’s pretty easy to build. Maybe we’ll see you enter a codeshare soon? :slight_smile:

Finally blogged:

Use a 74HC595 to monitor many digital inputs:

1 Like

@ wbsimms - I have encountered a problem. I have constructed the input sensor and am ready to go out to the garage and use it to monitor 4 doors. I am using reed switches which are normally closed when a door is shut. I want an interrupt when a door is opened. Since the switches are closed the interrupt sense line voltage is high. Opening a door will just open one of the door sensing circuits and won’t change the state of the interrupt voltage. I can still poll the doors but I would really like the interrupt to work. Do you have any thoughts on how I can modify the design?