Jump to content

Suggestions on connecting Membrane 1x4 Keypad to OrangePi PC+


Johhny Blue

Recommended Posts

Hi Everyone.

 

I have been looking for a way to connect this keypad directly to my Orange Pi PC+ directly through gpio without resistors.

https://www.adafruit.com/product/1332

 

I also need software (hopefully either bash or python) to read a key press and then either run a script or perform a command.

 

If anyone here done this or even connected 1 switch to gpio (without resistors), could you please post the solution or a link to follow.

 

Thanks.

V

Link to comment
Share on other sites

You can simply use GPIO internal pullups by enabling them.

By using orangepi_PC_gpio_pyH3 ( https://github.com/duxingkei33/orangepi_PC_gpio_pyH3), python code will look like :

from pyA20.gpio import gpio
from pyA20.gpio import port

gpio.setcfg(port.PA1, gpio.INPUT)
gpio.pullup(port.PA1, gpio.PULLUP)
if gpio.input(PA1) > 0:
    print "not pressed"
else:
    print "pressed"
Link to comment
Share on other sites

I have this python matrix keypad working on my rpi and hope someone can help me convert it to pyA20.

Thanks again.

 

#!/usr/bin/env python
import RPi.GPIO as GPIO
import time
import os
from time import sleep

GPIO.setmode(GPIO.BOARD)
MATRIX= [[1,2,3],
         [4,5,6],
         [7,8,9],
         ["u",0,"d"]
         ]
ROW=[7,11,13,15]
COL=[12,16,18]

for j in range(3):
    GPIO.setup(COL[j],GPIO.OUT)
    GPIO.output(COL[j],1)

for i in range(4):
    GPIO.setup(ROW[i],GPIO.IN,pull_up_down = GPIO.PUD_UP)
try:
    while(True):
                for j in range(3):
                    GPIO.output(COL[j],0)
                    for i in range(4):
                        if GPIO.input(ROW[i]) == 0:
                         print MATRIX [i][j]
                         print "/usr/local/bin/" + str(MATRIX [i][j])+".sh"
                         a = str("/usr/local/bin/" + str(MATRIX [i][j])+".sh")
			 print a
			 os.system (a)
			 sleep(0.2);
			 time.sleep(0.2)
                         while (GPIO.input(ROW[i])==0):
                                pass

                    GPIO.output(COL[j],1)
except KeyboardInterrupt:
    GPIO.cleanup()

Link to comment
Share on other sites

Guest
This topic is now closed to further replies.
×
×
  • Create New...

Important Information

Terms of Use - Privacy Policy - Guidelines