Skip to main content

The Pmod HAT Adapter  (144-8419)  makes it easy to connect Pmods to a Raspberry Pi. It supports plug-and-play functionality, only requiring that the host Raspberry Pi is booted with the Pmod HAT attached. The Pmod HAT has three 2×6 Pmod ports and provides access to additional I/O available via the Raspberry Pi 40-pin GPIO connector. Designed in collaboration with RS Components, users can take advantage of example Python libraries and demo tutorials hosted on DesignSpark.

KYPD (172-0813) is a 16-button keypad arranged in a hexadecimal format form 0 to F. By digitally driving a column line to a logic low level and digitally reading each of the rows, users can determine which button is currently pressed. This demonstrates how you could set up your own input by using this program.

Pmod_KYPD_9664e6bfa63966ffef7839614a7e458e3802fed4.png

Getting Started

In the first instance, we need to type the following commands on the terminal:

sudo apt-get update

sudo apt-get dist-upgrade

sudo apt-get install -y build-essential git libusb-1.0-0-dev libprotobuf-dev libleveldb-dev libsnappy-dev libopencv-dev libhdf5-serial-dev protobuf-compiler libatlas-base-dev git automake byacc lsb-release cmake libgflags-dev libgoogle-glog-dev liblmdb-dev swig3.0 graphviz libxslt-dev libxml2-dev gfortran python3-dev python3-pip python3-setuptools python3-markdown python3-pillow python3-yaml python3-pygraphviz python3-h5py python3-nose python3-lxml python3-matplotlib python3-numpy python3-protobuf python3-dateutil python3-skimage python3-scipy python3-six python3-networkx libfreetype6-dev libjpeg-dev python3-gst-1.0 python3-picamera

sudo pip3 install pyserial

sudo pip3 install designspark.pmod

Next, we have to turn on the serial function of the Raspberry Pi:

sudo raspi-config

>5 Interfacing Options
>6 serial
>Would you like a login shell to be accessible over serial?
>No
>Would you like the serial port hardware to be enabled?
>Yes

This program code means that we have to insert the Pmod KYPD into the Pmod HAT Adapter JA slot.

if __name__ == '__main__':
    
    KYPD = createPmod('KYPD','JA')
    time.sleep(0.1)

Next, plug the Pmod KYPD into the JA slot labelled below:

JA1_2f4151ff52e0ba877b3ab213a04ca463d98623ce.png

try:
        # set default key map
        KYPD.setKeyMapDefault()
        
        # set User Key Map
        # keyMap=[['A','B','C','D'],['E','F','G','H'],['I','J','K','L'],['M','N','O','P']]
        # KYPD.setKeyMap(keyMap)
        
        # get keyMap
        print(KYPD.getKeyMap())
        while True:
            # print(KYPD.getColRow())
            print(KYPD.getKey())
            time.sleep(0.5)
    except KeyboardInterrupt:
        pass
    finally:
        KYPD.cleanup()

The KYPD.getKeyMap is the function that sets what you want to print on the terminal in keyMap.

You can change the KeyMap as your desire.

sudo python3 /home/pi/Desktop/DesignSpark/example/KYPD_example.py

or 

sudo python /home/pi/Desktop/DesignSpark/example/KYPD_example.py 

Screenshot_2020-01-03_at_10.18_.24_AM__54b76811a61f353fcf497d2030d79d69c1565919.png

Downloads

Brian0925 has not written a bio yet…