connect@howdiyworld.com
|

## BLOCK DIAGRAM ### Procedure

1. 3 x 4 Matrix Keypad
2. Connections
3. Program
4. Output

Matrix keypad is the most commonly used input device in many of the application areas like digital circuits, telephone communications, calculators, ATMs, and so on. A matrix keypad consists of a set of push button or switches which are arranged in a matrix format of rows and columns. ## Connection

·       Connect keypad’s 1st pin to 31st pin.

·       Connect keypad’s 2nd pin to 29th pin.

·       Connect Keypad’s 3rd pin to 27th pin.

·       Connect keypad’s 4th pin to 23rd pin.

·       Connect keypad’s 5th pin to 37th pin.

·       Connect keypad’s 6th pin to 35th pin.

·       Connect keypad’s 7th pin to 33rd pin. ## Python programming

import RPi.GPIO as GPIO

from time import sleep

GPIO.setwarnings(False)

GPIO.setmode(GPIO.BCM)       # Use BCM GPIO numbers

GPIO.setup(26,GPIO.OUT)#c1

GPIO.setup(19,GPIO.OUT)#c2

GPIO.setup(13,GPIO.OUT)#c3

GPIO.setup(6,GPIO.IN,pull_up_down=GPIO.PUD_DOWN)#R1

GPIO.setup(5,GPIO.IN,pull_up_down=GPIO.PUD_DOWN)#R2

GPIO.setup(0,GPIO.IN,pull_up_down=GPIO.PUD_DOWN)#R3

GPIO.setup(11,GPIO.IN,pull_up_down=GPIO.PUD_DOWN)#R4

print(“Enter the Numbers")

while True:

GPIO.output(26,True)

GPIO.output(19,False)

GPIO.output(13,False)

a1=GPIO.input(6)

a2=GPIO.input(5)

a3=GPIO.input(0)

a4=GPIO.input(11)

if a1==GPIO.HIGH:

print(“1")

sleep(0.5)

if a2==GPIO.HIGH:

print(“4")

sleep(0.5)

if a3==GPIO.HIGH:

print(“7")

sleep(0.5)

if a4==GPIO.HIGH:

print(“*")

sleep(0.5)

GPIO.output(19,True)

GPIO.output(26,False)

GPIO.output(13,False)

a1=GPIO.input(6)

a2=GPIO.input(5)

a3=GPIO.input(0)

a4=GPIO.input(11)

if a1==GPIO.HIGH:

print(“2")

sleep(0.5)

if a2==GPIO.HIGH:

print(“5")

sleep(0.5)

if a3==GPIO.HIGH:

print(“8")

sleep(0.5)

if a4==GPIO.HIGH:

print(“0")

sleep(0.5)

GPIO.output(13,True)

GPIO.output(26,False)

GPIO.output(19,False)

a1=GPIO.input(6)

a2=GPIO.input(5)

a3=GPIO.input(0)

a4=GPIO.input(11)

if a1==GPIO.HIGH:

print(“3")

sleep(0.5)

if a2==GPIO.HIGH:

print(“6")

sleep(0.5)

if a3==GPIO.HIGH:

print(“9")

sleep(0.5)

if a4==GPIO.HIGH:

print(“#")

sleep(0.5)