Code for using capitative touch pads on Explorer Hat Pro to drive motors


Hi folks,

I have the STS-Pi here with the Explorer Hat Pro and want to build the code up as I go along…

I’m using GPIOZero library by the good folks at Raspberry Pi and tested their Keyboard Controlled Robot Code which works perfectly on the Explorer Hat Pro driving the motors…

I’d like to use the 4 capacitative touchpads (numbered 1 - 4 on the Exp. Hat Pro?) but am not locating the particular code that could allow me to run this in conjunction with the keyboard.

That keyboard code is further below…
I’ve looked at the pinout page, technical/functional documents on the GitHub repo but nothing as yet.

Something like -

  • touch-capacitator-1 for-one-second robot.forward
  • touch-capacitator-2 for-one-second robot.stop

Any ideas?
Cheers, Michael.

GPIOZero Keyboard Controlled Robot Code
import curses
from gpiozero import Robot

robot = Robot(left=(21, 26), right=(19, 20))

actions = {
curses.KEY_UP: robot.forward,
curses.KEY_DOWN: robot.backward,
curses.KEY_LEFT: robot.left,
curses.KEY_RIGHT: robot.right,

def main(window):
next_key = None
while True:
if next_key is None:
key = window.getch()
key = next_key
next_key = None
if key != -1:
action = actions.get(key)
if action is not None:
next_key = key
while next_key == key:
next_key = window.getch()



Have a look at the examples, here,
The might get you some info on how to do it.

The function reference may also help.