The Circuit Playground Express has two buttons. Button A is on the left and button B is on the right. We can use these buttons to update our board’s status when pressed.
We can access the statuses of the buttons using:
from adafruit_circuitplayground.express import cpx while True: if cpx.button_a: # code when Button A is pressed elif cpx.button_b: # code when Button B is pressed
while loop, we are going to add an if, else if, else statement:
cpx.button_ais pressed, set
cpx.button_bis pressed, set
Else, turn all the NeoPixels off.
Click the Download button to download the code.py file.
Drag and drop the downloaded file into the CIRCUITPY drive on your computer.
Press the button A a few times and press the button B a few times.