- MicroPython Cookbook
- Marwan Alsabbagh
- 89字
- 2021-06-24 14:28:23
How to do it...
Let's perform the following steps:
- Run the following lines of code in the REPL. The value of cpx.touch_A1 is False because touchpad A1 is not being touched:
>>> from adafruit_circuitplayground.express import cpx >>> cpx.touch_A1 False
- Keep your finger touching touchpad A1 while you run the following code block:
>>> cpx.touch_A1 True
- The following code should be added to the main.py file. This will print a message every time you press touchpad A1:
from adafruit_circuitplayground.express import cpx import time while True: if cpx.touch_A1: print('detected touch') time.sleep(0.05)