Oh my! Some pretty nasty self-imposed restrictions there Hank'.
There are smaller switches (see below, just left of the machined socket). And if you think about it, that tri-color LED actually has four states (off, red, green, and yellow).
Good luck on your project.
** added **
Someone just wrote to ask about the driver for that mux'd switch & LED drawing so I'll add it here if nobody minds. And sorry for the C code (I don't have PBP)...
The routine sets the four pins to inputs to read the switches. Standard 'parallel' switch state logic filters out all but a "new press" state while ignoring the other three states (for each switch). 1-of-N logic (only 1 mode on at any time) dictates that we save the "new press" pattern as the new "mode". Since a pressed switch could short out a pin that is set to output '1' we cannot turn off the inactive LEDs by outputting a '1' and so we leave those pins tri-stated (RC3..RC0 output latch bits are maintained at '0').
Code:/* * * isr debounce & switch state management (1-of-N switch logic) * * using 8 to 32 msec interrupt intervals * * * * swnew ____---____-----___ new switch sample * * swold _____---____-----__ switch state latch * * delta ____-__-___-____-__ changes, press or release * * newhi ____-______-_______ filter out new release bits * * */ trisc |= 0x0F; // set RC3..RC0 to inputs swnew = ~portc; // sample active lo switches swnew &= 0x0F; // on RC3..RC0 pins swnew ^= swold; // changes, press or release swold ^= swnew; // update switch state latch swnew &= swold; // filter out new release bits if(swnew) // if "new press" mode = swnew; // save 1000,0100,0010, or 0001 trisc ^= mode; // light the correct mode LED




Bookmarks