Skip to content
View in the app

A better way to browse. Learn more.

Armbian Community Forums

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

armbian orange pi: read matrix keypad 4x4 in python

Featured Replies

i used  this python script to read matrix 4x4 keypad data to raspberry pi 

 

import RPi.GPIO as GPIO  #raspberry pi
import time

# these GPIO pins are connected to the keypad  RPI
L1 = 21
L2 = 23
L3 = 27
L4 = 29

C1 = 31
C2 = 33  
C3 = 35
C4 = 37

# Initialize the GPIO pins
GPIO.setwarnings(False)
GPIO.setmode(GPIO.BCM)

GPIO.setup(L1, GPIO.OUT)
GPIO.setup(L2, GPIO.OUT)
GPIO.setup(L3, GPIO.OUT)
GPIO.setup(L4, GPIO.OUT)

# Make sure to configure the input pins to use the internal pull-down resistors
GPIO.setup(C1, GPIO.IN, pull_up_down=GPIO.PUD_DOWN)
GPIO.setup(C2, GPIO.IN, pull_up_down=GPIO.PUD_DOWN)
GPIO.setup(C3, GPIO.IN, pull_up_down=GPIO.PUD_DOWN)
GPIO.setup(C4, GPIO.IN, pull_up_down=GPIO.PUD_DOWN)

# It sends out a single pulse to one of the rows of the keypad
# and then checks each column for changes
# If it detects a change, the user pressed the button that connects the given line
# to the detected column

def readLine(line, characters):
    GPIO.output(line, GPIO.HIGH)
    if(GPIO.input(C1) == 1):
        print(characters[0])
    if(GPIO.input(C2) == 1):
        print(characters[1])

    if(GPIO.input(C3) == 1):
        print(characters[2])

    if(GPIO.input(C4) == 1):
        print(characters[3])

    GPIO.output(line, GPIO.LOW)

try:
    while True:
        # call the readLine function for each row of the keypad
        readLine(L1, ["1","2","3","e"])
        readLine(L2, ["4","5","6","r"])
        readLine(L3, ["7","8","9","t"])
        readLine(L4, ["q","0","w","y"])
        time.sleep(0.2)
except KeyboardInterrupt:
    print("\nApplication stopped!")

 

 

How can i create similar script for orange pi in armbian (in my case orange pi pc plus)?

it can by python or other language  doesnt matter

Edited by ari1234

  • ari1234 changed the title to armbian orange pi: read matrix keypad 4x4 in python
Guest
This topic is now closed to further replies.

Account

Navigation

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.