![MicroPython Cookbook](https://wfqqreader-1252317822.image.myqcloud.com/cover/609/36698609/b_36698609.jpg)
上QQ阅读APP看书,第一时间看更新
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)