This microcontroller is an excellent introductory board for anyone new to electronics. It's kid-friendly, with alligator clip connectors that require no soldering and a drag-and-drop code editor. But it's also packed with sensors and outputs, as well as offering the ability to convert your code to Javascript and tweak it in text format. Good stuff!
The Express offers a few upgrades to the classic Circuit Playground: infrared transmit/receive functions (to use it as a remote and detect distance); more touch inputs; much more coding options; and, importantly, a spot to write your name.
For video learners, here's our introduction to the board:
...And a video tutorial for this project:
Physical setupAll you need to get started is your Circuit Playground Express and a Micro USB cable! Pretty much everything is built-in.
CodeJump over to makecode.adafruit.com and start dragging and dropping. You don't even need to sign in! (What am I even doing here? You don't really need a tutorial...)
Let's do a quick Sorting Hat tutorial, in honor of today being the 20th anniversary of Harry Potter! You can open the code by clicking here.
You'll always start with a forever
loop on the board. Go click on the Light menu in the sidebar, select the show animation
option, and drag it into place inside the loop.
I chose the "Sparkle" animation from the dropdown menu, which I think looks a little more magical.
Next, find the on > shake
option in the Input menu. Anything placed inside this block's arms will happen when you wiggle the board.
The Variables menu will give you the option to create a value called "item", and the Math menu lets you plug in a random number from 0 to 3. I renamed the item
variable to house
, by clicking on it and choosing "Rename variable..." from the dropdown.
Next, the Logic menu provides an if/else
block. Click the settings icon to add "else if..." layers to the block, then click that icon again to close it. Slot in your house
variable (now available in the Variables menu) and assign the four house colors to the integers 0-3: red for Gryffindor, blue for Ravenclaw, yellow for Hufflepuff, and of course, green for Slytherin. The set all pixels to...
option is under the Light menu.
Finally, add one more touch of sparkle by playing the magic wand sound from the Music block. This goes after the entire if/else block. It's really annoying. You're welcome.
That's it for programming! Name your code file at the bottom of the page, then hit the big pink "Download" button next to it. You'll get a .uf2 file, which will download to your computer.
Plug in your Circuit Playground Express and hit the RESET button. Then, drag the .uf2 file onto the "CPLAYBOOT" disk that appears. Your board will restart – which may cause Mac OS to display a warning about ejecting the disk before disconnecting – and your code will be live!
At any point, you can see the results of your code in the simulator to the left of the programming environment. You can also turn off the simulator if you're low on bandwidth, or run it in slow motion by clicking the turtle: great for debugging if you're not sure why your code is acting weird.
I've now added a pause to the end, so it waits a moment (debounces) before Sorting again:
Have fun, and good luck with your Sorting!
Comments
Please log in or sign up to comment.