Make a Snow Globe with Circuit Playground Express & MakeCode
2017-12-18 | By Adafruit Industries
License: See Original Project Circuit Playground
Courtesy of Adafruit
Guide by Liz Clark
Introduction
Although people may have mixed feelings about snow, I think we can all agree that snow globes are pretty sweet. You can make one that’s even sweeter than the average globe using a Circuit Playground Express board and MakeCode to have a musical NeoPixel orb of holiday fun!
The Circuit Playground Express is a great board for this project since it has so many modules that you can control without any extra wiring. It’s also the perfect form factor to hide away snuggly in the base of your snow globe along with a battery to keep the fun powered on.
You can write code to easily control these modules with MakeCode, a visual coding app from Microsoft. MakeCode uses drag and drop blocks, like Scratch, to code rather than typing in a coding language. Of course, you can also use JavaScript with MakeCode as well if you really want to give your keyboard a workout.
Programming with MakeCode
For this project, I’m using the accelerometer, speaker and ring of NeoPixels on the Circuit Playground Express. I have the code running so that when you shake the Circuit Playground, the NeoPixels animate in the rainbow effect and it plays some music.
It’s fairly easy to program music into a project with MakeCode. You use the note blocks to select your note and how many beats you want the note to play for. There’s even a small piano keyboard that opens up with it if you want to write your own music on the fly. To have the NeoPixels change with the music, I have the animation advancing by one frame after each note is played. The music and NeoPixel code blocks are nested in a function box called “playMusic” so that I can put a function block inside of the “On Shake” block. This tells the Circuit Playground to play the music and light up the lights every time its shaken.
function playMusic() {
music.setVolume(100)
music.setTempo(145)
light.showAnimationFrame(light.rainbowAnimation)
music.playTone(131, music.beat(BeatFraction.Half))
light.showAnimationFrame(light.rainbowAnimation)
music.playTone(196, music.beat(BeatFraction.Half))
light.showAnimationFrame(light.rainbowAnimation)
music.playTone(262, music.beat(BeatFraction.Half))
light.showAnimationFrame(light.rainbowAnimation)
music.playTone(131, music.beat(BeatFraction.Half))
light.showAnimationFrame(light.rainbowAnimation)
music.playTone(196, music.beat(BeatFraction.Half))
light.showAnimationFrame(light.rainbowAnimation)
music.playTone(262, music.beat(BeatFraction.Whole))
light.showAnimationFrame(light.rainbowAnimation)
music.playTone(131, music.beat(BeatFraction.Half))
light.showAnimationFrame(light.rainbowAnimation)
music.playTone(196, music.beat(BeatFraction.Half))
light.showAnimationFrame(light.rainbowAnimation)
music.playTone(262, music.beat(BeatFraction.Half))
light.showAnimationFrame(light.rainbowAnimation)
music.playTone(131, music.beat(BeatFraction.Half))
light.showAnimationFrame(light.rainbowAnimation)
music.playTone(196, music.beat(BeatFraction.Half))
light.showAnimationFrame(light.rainbowAnimation)
music.playTone(262, music.beat(BeatFraction.Whole))
light.showAnimationFrame(light.rainbowAnimation)
music.playTone(523, music.beat(BeatFraction.Whole))
light.showAnimationFrame(light.rainbowAnimation)
music.playTone(587, music.beat(BeatFraction.Half))
light.showAnimationFrame(light.rainbowAnimation)
music.playTone(659, music.beat(BeatFraction.Whole))
light.showAnimationFrame(light.rainbowAnimation)
music.playTone(659, music.beat(BeatFraction.Half))
light.showAnimationFrame(light.rainbowAnimation)
music.playTone(587, music.beat(BeatFraction.Half))
light.showAnimationFrame(light.rainbowAnimation)
music.playTone(523, music.beat(BeatFraction.Whole))
light.showAnimationFrame(light.rainbowAnimation)
music.playTone(587, music.beat(BeatFraction.Whole))
music.rest(music.beat(BeatFraction.Half))
light.showAnimationFrame(light.rainbowAnimation)
music.playTone(523, music.beat(BeatFraction.Double))
light.showAnimationFrame(light.rainbowAnimation)
music.playTone(523, music.beat(BeatFraction.Whole))
light.showAnimationFrame(light.rainbowAnimation)
music.playTone(587, music.beat(BeatFraction.Half))
light.showAnimationFrame(light.rainbowAnimation)
music.playTone(659, music.beat(BeatFraction.Whole))
light.showAnimationFrame(light.rainbowAnimation)
music.playTone(659, music.beat(BeatFraction.Breve))
light.showAnimation(light.rainbowAnimation, 2000)
music.stopAllSounds()
}
input.onGesture(Gesture.Shake, function () {
for (let i = 0; i < 2; i++) {
playMusic()
}
light.stopAllAnimations()
light.clear()
})
Link to download the exported .uf2 MakeCode
Snow Globe Assembly Prep
After you have your code written, it’s time to tackle the making of the snow globe.
You’ll need:
- An empty snow globe
- A figurine or small plastic item
- Distilled water
- Glue (E6000 is good choice)
- Envirotex
- Glycerin
- Glitter
Your first step is to glue your special item that will be on display in your snow globe onto the inner base of snow globe using the E6000 glue. I recommend letting it set for 24 hours at least. You want to make sure that your item is secure and that the glue won’t be affected by the water or other ingredients.
After your glue has permanently stuck your item, it’s time to seal it and the base to ensure that it will survive the water, glycerin, and glitter (if you’re feeling brave). I used Envirotex, which is a resin-based waterproof seal that was recommended in the directions that came with my empty snow globe.
If you do decide to use the sealer, please follow the directions closely on the packaging to stay safe and to also have a successful project. I recommend mixing any of these concoctions in disposable containers with something like a popsicle stick to keep clean-up simple.
Depending on your chosen resin, dry times may vary. Mine was recommended to set for eight hours but I ended up letting it sit for 24 hours to ensure that everything was at optimal seal.
How it looks after 24 hours of setup
Putting It All Together
Once that step is all set though, it’s time to assemble the globe!
With your glued item and base at the ready, balance the globe portion with the opening up so that you can begin adding the distilled water. To account for the displacement from your item, I recommend filling the globe about halfway and then putting the base in to see how it affects the water level so that you don’t accidentally overfill. I would also test again before going for the final fit.
When you have a good water level, add the glycerin and glitter. The glycerin adds some thickness to the water that allows the glitter to float a bit better and give the snow globe that dreamy effect. I added about a ½ tsp of glycerin and a few shakes of glitter. Proportions aren’t especially important here though since you can mix to taste but what I did should give you a good baseline. I recommend mixing the water, glycerin, and glitter together before the next steps.
After your water concoction is mixed, it’s time for the moment of truth: inserting the base! Squeeze a thin layer of E6000 glue around the sides of the base so that a seal is created for the globe. Then, push the base in slowly, making sure that you’re getting a tight fit. With the globe still upside down, place another line of E6000 glue, this time around the top of the seal to block any possible leaks. This should be left to dry for a few hours, but that time will be worth it if it means no wet electronics.
Add Electronics & Shake!
After that dries, you have a custom DIY snow globe! But, it seems to be missing something…oh, that’s right, we need to add the electronics!
Grab your programmed Circuit Playground Express and place it into the base of the snow globe so that the NeoPixels are pointing up towards the inside of the globe. Plug a lipo battery into the Circuit Playground’s JST connector for power. Close-up the bottom portion of the snow globe with the screw on base to keep the Circuit Playground nice and snug and then shake away for music, lights and shimmering glitter!
Have questions or comments? Continue the conversation on TechForum, DigiKey's online community and technical resource.
Visit TechForum