Controlling 8 CMOS switches

Hi

A new project and a new problem.

For my current project I need to control 8 CMOS spst switches.

My proposed set up is 8 momontary push button switches:
two banks of 4 which control different functions.
(1 to 4) bank 1 and
(5 to 8) bank 2 are to control spst cmos switches (switches are normally open).

I need to have multiple combinations ie. 1,3,5 & 7 or 2,4,5 & 8 etc or possibly all switches closed or just 1 switch open.

My initially thoughts where about using a CD4021 (as I happen to have one) 8bit parallel to serial shift register, as used in the Shift in tutorial to read the 8 buttons, Then shift out the bits to a 74HC595 shift register controlling the cmos switches (CD4066) or alternately use the MAX335 (8 spst cmos switches, has a built in shift register and can be used on the SPI bus). A serialy connected 74HC595 would be used to contol LED's indicating the status of the switches.

Reading the Shift In tutorial and various tutorials on the web (toxicstuff and Nick Gammon web pages), I get the impression that the functionality that I require is not available from using the CD4021 or 74HC165. In that a a single push of any of the momentary push buttons will overide the existing state; and multiple button combinations is not possible. I have read the relevent section about mechanical switches buttons etc in the playground, and didn't find any information there, or maybe I missed it, same with searching the forum.

Now for my Questions:

Is there a way of latching the shifted in bits so that a switch will remain closed (LED lit) until its corrisponding control button is pressed again? If so could someone point me in the right dirrection.

Should I be thinking of the momentary push buttons as a key pad?

I have woundered if there is an alternative hardware solution?

Would it be simpler to use an I / O expander (PCF8574) and connect the control buttons to it, but I still don't see how to go about latching the switches.

Any advice or pointers as to hardware selection, or software would be gratefully received.

I think this is possible and I bet the solution is a lot simpler than I imagine.

best regards

Kevin

KRBrown:
...
Now for my Questions:

Is there a way of latching the shifted in bits so that a switch will remain closed (LED lit) until its corrisponding control button is pressed again? If so could someone point me in the right dirrection.
...
I think this is possible and I bet the solution is a lot simpler than I imagine.

best regards

Kevin

Hej Kevin,
I was looking for something else and read your post. I don't know most of what you write about, but making a LED stay lighted between two pushes is as easy as you sense.
Think of it as a state .. it switches between say an on and off state. When you programatically detects a push, then flip a boolean variable false/true. Execute a line of code that tests the value .. if it's on - light the LED,if it's off - turn the LED off.

You could certainly achieve that using shift registers, but why don't you connect the input switches and the output CMOS switches directly to Arduino pins? It would save a fair amount of extra complexity.

Hi Peter

8 inputs (momentary push buttons), 8 spst switches, 8 leds to show switch state. I was planning on using my UNO - (sorry forgot to mention what board I was using :blush:), so I lack a few output pins, hence I was looking into adding extra input output pins. Maybe over complicating a simple project, but I was looking on it as a learning experience as well, hence I was looking into shift registers.

I will consider your suggestion, maybe connecting the push buttons to the UNO directly and using shift registers for the output.

CarstenT:
Think of it as a state .. it switches between say an on and off state. When you programatically detects a push, then flip a boolean variable false/true. Execute a line of code that tests the value .. if it's on - light the LED,if it's off - turn the LED off.

Carsten thank you for your input it actually puts into words what I have been trying to sort out in my head since I asked my original question. I knew there was an easy solution to keeping the switch and LED in the closed (lit)state I will try it this evening if I get time.

Regards

Kevin

Given that you can read back the current state of an output pin, you don't strictly need to define a variable to remember it. You could simply do edge detection on the input switch to detect the button press (or release) and toggle the associated output pin.