- MicroPython Cookbook
- Marwan Alsabbagh
- 99字
- 2021-06-24 14:28:17
How it works...
The first line of code imports the Circuit Playground Express library. The cpx object exposes a property called button_a. This property will return True when the button is pressed, and it will return False when the button is not pressed.
The script loops forever with a 50 millisecond delay between each loop. The state of the button press is continually printed. When running this program, hold and release the push button to see the printed output change.
Note that there is another property called button_b, which serves the same function but for push button B instead.