Download Input Switches
Transcript
Vcc Keyboard Matrix of Switches (cont.) Keyboard Matrix of Switches 12 00 01 02 10 11 12 74LS151 8-to-1 Input Multiplexer A 06 07 I0 I1 17 I2 Scanned Switch Data I3 To Input Port I4 Z I5 I6 B 70 71 77 I7 E S2 S1 S0 • A keyboard is an array of switches arranged in a two-dimensional matrix. • A switch is connected at each intersection of vertical and horizontal lines. • Closing the switch connects the horizontal line to the vertical line. • 8*8 keyboard can be interfaced directly into 8-bit output and input ports at point A and B. Vcc O0 O1 E3 E2 O2 E1 74LS138 3-of-8 Decoder S2, 2008 O3 O4 O5 A2 O6 A1 O7 A0 Select Input From Output Port Scan Input From Output Port COMP9032 Week8 9 S2, 2008 COMP9032 Week8 Keyboard Matrix of Switches (cont.) Ghosting • Software can scan the key board by outputting a three-bit code to the decoder and then scanning the multiplexer to find the closed switch or switches. Vcc R3 – The combination of the two 3-bit scan codes (A2A1A0 and S2S1S0) identifies which switch is closed. For example, the code 000000 scan switch 00 in the upper left-hand corner. • The diode prevents a problem called ghosting. S2, 2008 COMP9032 Week8 10 R2 R1 Col 0 Col 1 Col 2 00 01 02 10 11 12 20 21 22 Row 0 (Pulled low, error) Row 1 (Pulled low, OK) Row 2 (High, OK) Low (Scanned column) 11 S2, 2008 COMP9032 Week8 12