How to do it...

Follow these steps to learn how to create a joke-telling machine:

  1. Run the following lines of code in the REPL:
>>> from displayio import OnDiskBitmap, ColorConverter, TileGrid, Group
>>> import board
>>> import random
>>> import time
>>> import touchio
>>> import os
  1. We have now imported all the necessary modules. The following block of code will create a TouchIn object:
>>> touch = touchio.TouchIn(board.TOUCH1)
  1. In the following block of code, we will check the status of the touchpad:
>>> touch.value
  1. Touch the pad while executing the following block of code:
>>> touch.value
  1. The following block of code will define the wait_for_touch function, which will keep looping until a touch event is detected: ...

Get MicroPython Cookbook now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.