制造商零件编号 3333
CIRCUIT PLAYGROUND EXPRESS
Adafruit Industries LLC
License: See Original Project Circuit Playground
Courtesy of Adafruit
Guide by Erin St Blaine
Overview
Turn your Valentine candy box into a magical powered-up PowerPuff Girls project with Circuit Playground Express. Download our code, or create your own custom lights and sounds with Microsoft's MakeCode drag-and-drop code editor.
This is a great project to do with kids. There is a little bit of cutting required, but no soldering. Help them surprise Mom with an extra special Valentine present from both of you.
Tools & Materials
You'll also need:
Circuit Diagram
Connect a strip of copper tape with a touch pad at the end to pins A1, A5 and A7. Plug the battery into the JST connector on the Circuit Playground, switch it on, and you're ready to go!
Code with MakeCode
MakeCode is Microsoft's drag-and-drop code editor. It makes it easy for beginners and/or kids to get up and running with the Circuit Playground Express. So many options are accessible and easy with MakeCode, and it's really fun to customize and play around with making blinky lights and sounds.
Here's the completed project. Click the Download link at the bottom, plug your Circuit Playground Express into your computer and drag the file onto the resulting CPLAYBOOT drive.
Or, follow along below to create your own project from scratch.
input.pinA1.onEvent(ButtonEvent.Click, function () {
light.showRing(
`green green green green green green green green green green`
)
music.playSound(music.sounds(Sounds.PowerUp))
})
input.pinA5.onEvent(ButtonEvent.Click, function () {
light.showRing(
`pink pink pink pink pink pink pink pink pink pink`
)
music.playSound(music.sounds(Sounds.JumpUp))
})
input.pinA7.onEvent(ButtonEvent.Click, function () {
light.showRing(
`blue blue blue blue blue blue blue blue blue blue`
)
music.playSound(music.sounds(Sounds.MagicWand))
})
forever(function () {
})
Code It Yourself
Head to https://www.makecode.com and choose the Circuit Playground Express. Select "New Project" and give it a name. I called mine "PowerPuff."
Click the INPUT tab and drag 3 instances of on button A click into your workspace. Change all 3 button A dropdowns to read pin A1, pin A5 and pin A7respectively, since those are the pins we will connect to.
Add the color! Click the LIGHT tab and drag an instance of show ring into each of the three input blocks. Select the color you want for each. I chose colors that correspond with the outfit color of each PowerPuff Girl. Change colors by clicking the wedge in the center of the ring that shows the color you want, then click each light to make it that color.
Add the sounds. Click the MUSIC tab and drag an instance of play sound into each input block. MakeCode has a variety of sounds you can choose from, so pick your favorite sound for each PowerPuff girl. You can hear what they sound like by using the emulator on the left once you've got the sounds into your project.
Plug your Circuit Playground Express into your computer using a USB cable. You will see a rainbow animation appear the first time it boots up. Click the tiny Reset button in the middle of the board and the lights will all turn red, then green. When the lights turn green, a new drive will appear on your computer called CPLAYBOOT.
In MakeCode, click the Download button to download your code to a file. Drag this file onto the CPLAYBOOT drive. The Circuit Playground Express will reboot and eject itself.
Touch the three pads you selected one at a time to make sure you like the light and sound effects. Customize to your heart's content!
Troubleshooting
If you're having trouble, head over to the Circuit Playground Express tutorial for more troubleshooting ideas.
Assembly
Here is the printable image, sized for a small to medium sized candy box.
Open your candy box and cut some of the plastic lining out near the bottom, to make space for the battery box. (It's okay to eat the chocolates that no longer fit.)
Cut a small hole in top of the box near the bottom for the battery connector to come through. Stick the battery case to the inside of the lid with some double sided tape. Stick the Circuit Playground Express on the outside of the box and plug in the battery.
Print out the PowerPuff Girls graphic on some card stock and place it on top of your box to be sure it's a good size. Cut the image out. Use some more double-sided tape to stick it to the front of the box above the Circuit Playground.
Cut three pretty shapes out of a length of copper tape. Taper each at the end so it will fit nicely through one of the holes on the Circuit Playground. Make your copper tape shapes long enough to reach each PowerPuff girl from her assigned Circuit Playground pin. Mine were about 4" (10 cm) long.
Slide one of your copper tape shapes through the hole at pin A1, one through pin A5 and one through pin A7. Be careful not to cross the tape shapes, or to touch any of the other pads on the Circuit Playground. It's fine to double-up or use multiple pieces of tape to route where you'd like.
Turn the power on using the switch on the battery box. Touch each piece of copper tape in turn, and watch the lights turn on and hear the sounds play. Hooray!
If you'd like, go back to the code and add custom animations or sounds. See if you can sound an alarm when the candy box is opened! You don't want anyone stealing your candy. (Hint: use the on shake input)
Troubleshooting
If it's not working, check to be sure that the copper tape's narrow end is firmly and tightly stuck to the correct pin pad on the Circuit Playground. Make sure the tape is not accidentally touching any of the other pads - this can make it malfunction. Add more layers of tape if needed.
If it's still not working, check your code and make sure you assigned the correct pins, and check to be sure your batteries are fresh/charged.