Wagner, First of all, I'm not about to have 10 SCRs lined up in a row for that... too much :) what happens in my code is that the 10 switches are encoded via a priority encoder. this outputs a 4 bit code of any switch that is pressed. (16 possible...). The code loops until that code does not equal 0000 (no switches pressed). once this happens, it exits the loop that checks for that case, and goes into the part that lights up the corresponding light. this is accomplished thru a simple 1 of 10 decoder... Meanwhile, other people can push switches, but their light won't light up cuz it's not even checking if that code is not 0000. Once reset, it again goes into the mode of checking that 0000 code. The whole circuit thus contains three chips... the PIC, and the encoder/decoder. Greg Wagner Lipnharski wrote: > > "Paul B. Webster VK2BZC" wrote: > > > > Greg Brault wrote: > > > > > I have 10 input switches (for 10 people). I also wanted to have 10 > > > output lights. As you know, a PIC's i/o pins do not suit this. I had > > > to do a little multiplexing... plus, I have a buzzer sound as well. > > > > Well the multiplexing is simple and elegant - I mentioned one approach > > in my answer to the Video Switcher ("Re: Multiplexing Questions") a week > > ago. > > > > An alternative approach, perhaps not entirely suitable for this > > particular application, is to share one switch and one lamp output on > > each I/O pin. You have switches pulling I/O lines to ground and those > > lines pulling down corresponding lamps returned to the Vcc rail (likely > > via buffers). > > > > This means that the lamps are *always* lit when the corresponding > > switch is closed, but are latched by the MCU detecting the logic low and > > setting that port line as a low output (else input of course). > > -- > > Cheers, > > Paul B. > > How fast can you read the switches and decide if any is pressed? > That loop speed would be the resolution between the 1st and 2nd person > pressing the switches. > You can have persons pressing switches with a time difference of only > half microsecond. Can you afford to say they pressed at the same time? > when they didn't? It can happens if in the previous loop port reading > there was no switch pressed, and at the next reading two switches are > pressed. > > Even using an interrupt triggered by any switch pressed, you can have > problems. The first person pressed the switch, triggers the interrupt. > During the interrupt service timing, a second person press a switch. The > interrupt routine will read the port and find two switches pressed... > who pressed first? > > The really best solution is use an electronic scheme that once one > switch is pressed, it just disable all other switches. Then the > microcontroller will read the port and will *always* find just one > switch pressed. > > One way to do that is just use small SCR's at each switch. All SCR's > gate have a resistor to ground. All SCR's cathode are grounded. The SCR > anode goes to the port pin pulled up by a resistor. There is another > pulled up (common) wire that goes to all button switches. The other side > of the button switch goes to its SCR's gate. Each SCR anode has a small > diode (diode cathode to SCR anode) going to the common wire. > > It means that once the first button is pressed, the common wire pulled > up voltage triggers its SCR, the SCR conducts its port pin to ground and > also grounds the common wire via its diode. No other SCR would be able > to be gated since the common wire has no more voltage. The SCR of the > first pressed switch still conducting, its port pin is zero, all other > port pins are up level. > > You can install a LED at the pull-up of the port pin, so just the first > switched would have the LED lighted. To reset the situation, just set > low all the port pins, it would remove the latch condition of the SCR > and it will go high impedance again. > > I don't have the minimum idea how fast the SCR can remove the voltage > from the common wire, and that would be the first to second person > timing resolution. > > -------------------------------------------------------- > Wagner Lipnharski - UST Research Inc. - Orlando, Florida > Forum and microcontroller web site: http://www.ustr.net > Microcontrollers Survey: http://www.ustr.net/tellme.htm