Jump to content

Recommended Posts

Posted

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

Posted

Thanks Man.

It is simple once you see it like you have written it.

On some other example I can see

import RPi.GPIO as GPIO

Is it as simple as swapping RPi.GPIO to pyA20.gpio and matching the correct pins?

V.

Posted

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()

Posted

Should be pretty straight forward ...

Only setup() needs to be changed to setcfg() along with separate pullup() call since setcfg() doesn't have the third argument.

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

Important Information

Terms of Use - Privacy Policy - Guidelines