Bruce Gennette wrote: > I need to select one-of-eight inputs and display (with an LED) which > input is currently selected. > But I need to do this twice, once for the video going out to the class > room monitors and once for the pre-view monitor. OK, let's use efficient LEDs so that 20mA for half the time will suffice to light each LED. You won't need transistors. LED in row 1 Set Port B pullups ON. To light +---|<|-------+ the LED in row 0, Set PA0 high, | Si P/B | PA1 tri-state (hint, use TRIS +-|>|--o/o----+ instruction, not bank select). ____ | LED in row|0 Clear PORTB and set a mask using PBx|--+---|<|-----+ | TRIS PORTB with the only zero in | | Si P/B | | the bit corresponding to the LED | +-|>|--o/o--+ | to be lit. | 180 ohm | | PA0|--VVVVV-------+-u--o Other After 8ms, set up the LED in | 180 ohm | row 0 row 1 in the same fashion (leave a PA1|--VVVVV---------+--o Other "1" in both bits 0 and 1 of port A. | row 1 ____| To read the row 0 switches, TRIS PORTB to $FF (inputs), set both bits 0 and 1 of PORTA to "0", TRIS PORTA bits 1,0 to "10" and read PORTB which will contain a "0" corresponding to any switch closed. Read row 1 switches with "01" in TRIS PORTA bits 1,0. The cycle of lighting the row 0 LED for 8ms, lighting the row 1 LED for 8ms, reading row 0 for about 5µs (i.e., insert a few NOPs between setting up the ports and reading PORTB) and reading row 1 for 5µs will both multiplex the LEDs and give you a basis for de-bouncing the push- buttons. You do not need interrupts to perform the timing; a prescale of 32 on TMR0 will allow you to poll its overflow flag for 8192µs intervals for a 4MHz crystal frequency. You set up the LED to be lit, go perform your other code for less than 8ms, then come back and poll the overflow flag until it shows, *clear the flag*, go set up the next LED and so on. -- Cheers, Paul B.