I know the 4x4 keypad is consist of a matrix of switch, but how do the microcontroller recognize with key is being pressed?
for example, B4 is connected to B0,B1, B2, and B3. When SW1 is pressed, B0 and B4 is closed, thus B4 is HI. However, when B4 is HI, how does it know that it is SW1, but not SW5 or SW9 is being pressed?
you pull b4 high and check b0-b3. if one of those is pressed you do sometihing
if none is pressed put it low and pull b5 high and again check b0-b3.if one of those is pressed you do sometihing
if none is pressed put it low and pull b6 high and again check b0-b3.if one of those is pressed you do sometihing
if none is pressed put it low and pull b7 high and again check b0-b3.if one of those is pressed you do sometihing
go back to start
like thatyou can push only one button at the time and you should use a piezo to accnolige that key has been pressed
An easier way is to use 8 bits. 4 for rows & 4 for columns. When a key is pressed, bits 0-3 will identify the row & bits 4-7 will identify the column & the controller will know precisely which key has been pressed.
you cat do that cause if you press a swich and all b's are inputs then there will be no change. all will still be in 0 position. the best and only way to operate this kwypad is the one is just described