Your Circuit Playground Express has a little red LED next to the USB port. It's labeled D13.
In EduBlocks, we are going to turn it on for half a second, then off for half a second, then back on etc. forever!
- First, go ahead and add the CPX Easy block extension if you haven't already. Directions on how to do that are back on the "Block Types" page in the "Navigating EduBlocks" section of this guide.
- From the
Basic
block category, drag inimport time
. - From
CPX Easy
, import the necessary library by dragging it over. - Next in
Basic
, drag over awhile True:
loop. This is the main loop of the program and will run forever until the CPX is disconnected from power or reset. - Now in
CPX Easy
, drag in acpx.red_led
block. Set the value in the white bubble toTrue
. - Now drag in a
time.sleep()
block and set the value to0.5
which will be half a second. - Now drag in another
cpx.red_led
block and set its value toFalse
. - Lastly, copy and paste the
time.sleep()
block from earlier by clicking on it, copying and pasting and dragging under the last block.
Once the blocks look good, click Download in the EduBlocks toolbar.
You may have to tell your browser you want to keep the file if asked.
A file named main.py should show up in downloads.
With the CPX plugged into the computer, drag main.py to the CIRCUITPY drive.
The drive should now have the file on it and the code should be running!
Is the LED blinking on and off on your CPX?
Issues? Troubleshooting help here.
Here are the code files if you want to upload directly to EduBlocks or the CPX.
import time from adafruit_circuitplayground.express import cpx while True: cpx.red_led = True time.sleep(0.5) cpx.red_led = False time.sleep(0.5)
Text editor powered by tinymce.