# LED Reactive Light-Up Hockey Puck in MakeCode

## Overview

https://youtu.be/XtGo_NXsA6g

In this project, we’re making a 3D printed LED hockey puck.

This was inspired by the DIY indoor hockey project by [Yuksel Timez](https://www.hackster.io/news/this-arduino-based-led-puck-brightens-up-indoor-hockey-8c310beacb0a).

This hockey puck lights up and makes chips tunes based on motion!

You get a light show each time you hit the hockey puck, so it's still super fun even when you miss a goal.

&nbsp;

![3d_printing_hero-hit-B.gif](https://cdn-learn.adafruit.com/assets/assets/000/098/083/medium640thumb/3d_printing_hero-hit-B.jpg?1608665338)

Either the **Circuit Playground Express** or the **Circuit Playground Bluefruit** make this a fun and easy project that uses the built-in motion sensor and NeoPixel LEDs.

The case was 3D printed in NinjaFlex filament which lets you use the buttons to switch between different animations.

With MakeCode for the Circuit Playground Express or MakeCode Maker, we were able to quickly make this demo.

MakeCode an easy to use block based code editor that's great if you're just getting started.

![3d_printing_buttons-loop-b.gif](https://cdn-learn.adafruit.com/assets/assets/000/098/084/medium640thumb/3d_printing_buttons-loop-b.jpg?1608665485)

![3d_printing_upside-down-loop-B.gif](https://cdn-learn.adafruit.com/assets/assets/000/098/096/medium640thumb/3d_printing_upside-down-loop-B.jpg?1608673327)

![](https://cdn-learn.adafruit.com/assets/assets/000/098/109/medium800thumb/3d_printing_cpx-hero-loop-sm.jpg?1608676956)

## Parts
Select either the Circuit Playground Express or the Circuit Playground Bluefruit.

Featured
### Circuit Playground Express

[Circuit Playground Express](https://www.adafruit.com/product/3333)
 **Circuit Playground Express** is the next step towards a perfect introduction to electronics and programming. We've taken the original Circuit Playground Classic and made it even better! Not only did we pack even more sensors in, we also made it even easier to...

In Stock
[Buy Now](https://www.adafruit.com/product/3333)
[Related Guides to the Product](https://learn.adafruit.com/products/3333/guides)
![A Black woman's manicured hand holds a round microcontroller with lit up LEDs.](https://cdn-shop.adafruit.com/640x480/3333-05.jpg)

Featured
### Circuit Playground Bluefruit - Bluetooth® Low Energy

[Circuit Playground Bluefruit - Bluetooth® Low Energy](https://www.adafruit.com/product/4333)
 **Circuit Playground Bluefruit** is our third board in the Circuit Playground series, another step towards a perfect introduction to electronics and programming. We've taken the popular Circuit Playground Express and made it even better! Now the main chip is an nRF52840...

Out of Stock
[Buy Now](https://www.adafruit.com/product/4333)
[Related Guides to the Product](https://learn.adafruit.com/products/4333/guides)
![shot of a Black woman's neon-green manicured hand holding up a Circuit Playground Bluefruit glowing rainbow LEDs.](https://cdn-shop.adafruit.com/640x480/4333-11.jpg)

Featured
### Adafruit Micro-Lipo Charger for LiPoly Batt with USB Type C Jack

[Adafruit Micro-Lipo Charger for LiPoly Batt with USB Type C Jack](https://www.adafruit.com/product/4410)
Oh so handy, this little lipo charger is so small and easy to use you can keep it on your desk or mount it easily into any project! Simply plug it via any USB C cable into a USB port and a 3.7V/4.2V lithium polymer or lithium ion rechargeable battery into the JST plug on the other end. There...

In Stock
[Buy Now](https://www.adafruit.com/product/4410)
[Related Guides to the Product](https://learn.adafruit.com/products/4410/guides)
![Adafruit Micro-Lipo Charger for LiPoly Batt with USB Type C Jack connected to Lipoly battery and USB cable. ](https://cdn-shop.adafruit.com/640x480/4410-05.jpg)

Featured
### Lithium Ion Polymer Battery with Short Cable - 3.7V 420mAh

[Lithium Ion Polymer Battery with Short Cable - 3.7V 420mAh](https://www.adafruit.com/product/4236)
Lithium-ion polymer (also known as 'lipo' or 'lipoly') batteries are thin, light, and powerful. The output ranges from 4.2V when completely charged to 3.7V. This battery has a capacity of 420mAh for a total of about 1.55 Wh. If you need a larger (or smaller!) battery, <a...></a...>

In Stock
[Buy Now](https://www.adafruit.com/product/4236)
[Related Guides to the Product](https://learn.adafruit.com/products/4236/guides)
![Lithium Ion Polymer Battery 3.7v 420mAh with JST 2-PH connector and short cable](https://cdn-shop.adafruit.com/640x480/4236-04.jpg)

Featured
### Fully Reversible Pink/Purple USB A to micro B Cable - 1m long

[Fully Reversible Pink/Purple USB A to micro B Cable - 1m long](https://www.adafruit.com/product/4111)
This cable is not only super-fashionable, with a woven pink and purple Blinka-like pattern, it's also fully reversible! That's right, you will save _seconds_ a day by not having to flip the cable around.

First let's talk about the cover and over-molding. We got these...

In Stock
[Buy Now](https://www.adafruit.com/product/4111)
[Related Guides to the Product](https://learn.adafruit.com/products/4111/guides)
![Fully Reversible Pink/Purple USB A to micro B Cable](https://cdn-shop.adafruit.com/640x480/4111-02.jpg)

&nbsp;&nbsp;

![3d_printing_parts.jpg](https://cdn-learn.adafruit.com/assets/assets/000/098/086/medium640/3d_printing_parts.jpg?1608669095)

![3d_printing_dowels.jpg](https://cdn-learn.adafruit.com/assets/assets/000/098/087/medium640/3d_printing_dowels.jpg?1608669228)

### Part: M3 x 12mm
quantity: 4
M3-0.50 x 12M
[M3 x 12mm](https://www.albanycountyfasteners.com/Flat-Socket-Head-Cap-Screw-3MM-Stainless-Steel-p/5470000.htm)

### Part: 7/8 Dowel 
quantity: 1
7/8 Dowel 
[7/8 Dowel ](https://amzn.to/3puu7jt)

# LED Reactive Light-Up Hockey Puck in MakeCode

## 3D Printing

## Parts List

STL files for 3D printing are oriented to print "as-is" on FDM style machines. Parts are designed to 3D print without any support material. Original design source may be downloaded using the links below.

- puck-cover.stl
- puck-btm.stl
- hockey-blade.stl

![3d_printing_3d-parts.jpg](https://cdn-learn.adafruit.com/assets/assets/000/098/097/medium640/3d_printing_3d-parts.jpg?1608673482)

![3d_printing_dowels.jpg](https://cdn-learn.adafruit.com/assets/assets/000/098/098/medium640/3d_printing_dowels.jpg?1608673559)

[Edit Puck Design](https://a360.co/3G3pffo)
[Download Puck Stls](https://www.thingiverse.com/thing:4694409)
[Edit Hockey Blade](https://a360.co/40JjDQK)
[Download Hockey Blade](https://www.thingiverse.com/thing:4694409)
## Slicing Parts
 **Hockey Blade**  
Slice the Blade part with settings for PETG material. The parts were sliced using CURA using the slice settings below.

**PETG filament**  
230c extruder  
0.2 layer height  
30% gyroid infill  
70c heated bed

**Circuit Playground Puck Case**  
Slice the Case parts with settings for TPU 98a material. The parts were sliced using CURA using the slice settings below.

**TPU 98a filament**  
230c extruder  
0.2 layer height  
30% gyroid infill  
50c heated bed

![3d_printing_print-loop-B.gif](https://cdn-learn.adafruit.com/assets/assets/000/098/100/medium640thumb/3d_printing_print-loop-B.jpg?1608674868)

![3d_printing_slice-loop-b.gif](https://cdn-learn.adafruit.com/assets/assets/000/098/101/medium640thumb/3d_printing_slice-loop-b.jpg?1608675484)

# LED Reactive Light-Up Hockey Puck in MakeCode

## MakeCode

## MakeCode for Adafruit Boards

MakeCode is an easy-to-use block-based programming editor that runs in the Google Chrome web browser. It’s has an intuitive interface and features lots of examples and demos.

![3d_printing_cpx-makecode.jpg](https://cdn-learn.adafruit.com/assets/assets/000/098/117/medium640/3d_printing_cpx-makecode.jpg?1608690997)

## LED Hockey Puck Code

If you are using the Circuit Playground Express, which uses [https://makecode.adafruit.com](https://makecode.adafruit.com), click the button below.

[Get the Hockey Puck Code for the Circuit Playground Express](https://makecode.com/_49HD7q8WURRK)
If you are using the Circuit Playground Bluefruit, which uses [https://maker.makecode.com/](https://maker.makecode.com/,), click the button below.

[Get the Hockey Puck Code for Circuit Playground Bluefruit](https://makecode.com/_T8qUTT60wKg7)
## Pair Device and Upload

Once you have the MakeCode program open, click the&nbsp; **edit** &nbsp;button on the top right to open it in a new MakeCode project.

The code blocks and simulator will be ready to modify. Let's get the device paired with WebUSB.

1. Click on the&nbsp; **Gear icon** , at the top right.
2. Select&nbsp; **Pair Device** &nbsp;from the dropdown.
3. For the Circuit Playground Express, Click on&nbsp; **CPlay Express** &nbsp;and&nbsp; **Connect.** For the Circuit Playground Bluefruit, click your device and click **Pair Device.**
4. Click the big blue&nbsp; **Download** &nbsp;button to upload the code.

![3d_printing_makecode-setting-pair.jpg](https://cdn-learn.adafruit.com/assets/assets/000/098/115/medium640/3d_printing_makecode-setting-pair.jpg?1608690916)

![3d_printing_makecode-board-pair.jpg](https://cdn-learn.adafruit.com/assets/assets/000/098/116/medium640/3d_printing_makecode-board-pair.jpg?1608690937)

## MakeCode Blocks
![](https://cdn-learn.adafruit.com/assets/assets/000/098/120/medium800/3d_printing_makecode-blocks.jpg?1608691400)

## on start

if true then

- while true do show animation (rainbow)

if button B is pressed then

while true do

- show animation (purple fireball) for 2ms

else if

- button A is pressed then
  - stop all animations&nbsp;
  - while button A is press do
    - show animation (blue chase) for 5000ms

## on button A click

- stop all animations
- While button A was pressed do
  - show animation (blue chase color) for 5000 ms

## on face down

stop all animations

- run in parallel
  - show animation (red orange color) for 5000 ms
  - play melody (falling)

## on 2g (step)

- play sound (pew pew)
- stop all animation
- show animation (sparkle)

on button A+B click

- reset

# LED Reactive Light-Up Hockey Puck in MakeCode

## Assemble

## Place Lipo Battery

Orient the battery so the wire connections are facing down.

## Align Circuit Playground

The battery port aligns with the flaps on the case.

![3d_printing_case-pocket.jpg](https://cdn-learn.adafruit.com/assets/assets/000/098/102/medium640/3d_printing_case-pocket.jpg?1608675786)

![3d_printing_case-bat-cpx.jpg](https://cdn-learn.adafruit.com/assets/assets/000/098/103/medium640/3d_printing_case-bat-cpx.jpg?1608676011)

## Attach screws

Align the flaps on both parts of the case and fasten four M3x12mm screws to each standoff.

&nbsp;

## Plug in Battery

Pull the lid flaps back to plug in and to disconnect the battery to the Circuit Playground.

To close the port opening, push the larger flap behind the shorter flap.

![3d_printing_m3-screws.jpg](https://cdn-learn.adafruit.com/assets/assets/000/098/104/medium640/3d_printing_m3-screws.jpg?1608676197)

![3d_printing_battery-flap.jpg](https://cdn-learn.adafruit.com/assets/assets/000/098/106/medium640/3d_printing_battery-flap.jpg?1608676586)

## Charging the Battery

The battery connector can reach out of case and plug into a USB [lipo charger](https://www.adafruit.com/product/4410) to recharge the battery.

![3d_printing_lipo-charging.jpg](https://cdn-learn.adafruit.com/assets/assets/000/098/107/medium640/3d_printing_lipo-charging.jpg?1608676724)

## Hockey Blade

&nbsp;

The hockey blade press fits into a [7/8 diameter dowel](https://amzn.to/3puu7jt).

Use an M3 screw to further secure the blade.

![3d_printing_dowels.jpg](https://cdn-learn.adafruit.com/assets/assets/000/098/122/medium640/3d_printing_dowels.jpg?1608692814)

![3d_printing_dowel-attached.jpg](https://cdn-learn.adafruit.com/assets/assets/000/098/123/medium640/3d_printing_dowel-attached.jpg?1608692873)


## Guide Products

### Circuit Playground Express

[Circuit Playground Express](https://www.adafruit.com/product/3333)
 **Circuit Playground Express** is the next step towards a perfect introduction to electronics and programming. We've taken the original Circuit Playground Classic and made it even better! Not only did we pack even more sensors in, we also made it even easier to...

In Stock
[Buy Now](https://www.adafruit.com/product/3333)
[Related Guides to the Product](https://learn.adafruit.com/products/3333/guides)
### Circuit Playground Bluefruit - Bluetooth® Low Energy

[Circuit Playground Bluefruit - Bluetooth® Low Energy](https://www.adafruit.com/product/4333)
 **Circuit Playground Bluefruit** is our third board in the Circuit Playground series, another step towards a perfect introduction to electronics and programming. We've taken the popular Circuit Playground Express and made it even better! Now the main chip is an nRF52840...

Out of Stock
[Buy Now](https://www.adafruit.com/product/4333)
[Related Guides to the Product](https://learn.adafruit.com/products/4333/guides)
### Adafruit Micro-Lipo Charger for LiPoly Batt with USB Type C Jack

[Adafruit Micro-Lipo Charger for LiPoly Batt with USB Type C Jack](https://www.adafruit.com/product/4410)
Oh so handy, this little lipo charger is so small and easy to use you can keep it on your desk or mount it easily into any project! Simply plug it via any USB C cable into a USB port and a 3.7V/4.2V lithium polymer or lithium ion rechargeable battery into the JST plug on the other end. There...

In Stock
[Buy Now](https://www.adafruit.com/product/4410)
[Related Guides to the Product](https://learn.adafruit.com/products/4410/guides)
### Lithium Ion Polymer Battery with Short Cable - 3.7V 420mAh

[Lithium Ion Polymer Battery with Short Cable - 3.7V 420mAh](https://www.adafruit.com/product/4236)
Lithium-ion polymer (also known as 'lipo' or 'lipoly') batteries are thin, light, and powerful. The output ranges from 4.2V when completely charged to 3.7V. This battery has a capacity of 420mAh for a total of about 1.55 Wh. If you need a larger (or smaller!) battery, <a...></a...>

In Stock
[Buy Now](https://www.adafruit.com/product/4236)
[Related Guides to the Product](https://learn.adafruit.com/products/4236/guides)
### Fully Reversible Pink/Purple USB A to micro B Cable - 1m long

[Fully Reversible Pink/Purple USB A to micro B Cable - 1m long](https://www.adafruit.com/product/4111)
This cable is not only super-fashionable, with a woven pink and purple Blinka-like pattern, it's also fully reversible! That's right, you will save _seconds_ a day by not having to flip the cable around.

First let's talk about the cover and over-molding. We got these...

In Stock
[Buy Now](https://www.adafruit.com/product/4111)
[Related Guides to the Product](https://learn.adafruit.com/products/4111/guides)

## Related Guides

- [Adafruit Circuit Playground Express](https://learn.adafruit.com/adafruit-circuit-playground-express.md)
- [Adafruit Circuit Playground Bluefruit](https://learn.adafruit.com/adafruit-circuit-playground-bluefruit.md)
- [Bass MIDI Stomp Box](https://learn.adafruit.com/midi-bass-synth-stomp-box.md)
- [MagTag Lists From Google Spreadsheets](https://learn.adafruit.com/collaborative-spreadsheets-to-magtag.md)
- [Make a Snow Globe with Circuit Playground Express & MakeCode](https://learn.adafruit.com/make-a-snowglobe-with-circuit-playground-makecode.md)
- [The Scream: Interactive Screaming Painting](https://learn.adafruit.com/the-scream-munch-screaming-interactive-scream-painting.md)
- [MEMENTO Wireless Remote with TouchOSC](https://learn.adafruit.com/memento-wireless-remote.md)
- [New Year Countdown Clock with Circuit Playground Express](https://learn.adafruit.com/new-year-countdown-clock-with-circuit-playground-express.md)
- [Trash-Built Robotic Fish](https://learn.adafruit.com/trash-robo-fish.md)
- [Sound Reactive Rapunzel Hair](https://learn.adafruit.com/sound-reactive-rapunzel-hair.md)
- [Circuit Playground Express Automatic Sunglasses](https://learn.adafruit.com/circuit-playground-express-auto-sunglasses.md)
- [Generating Text with ChatGPT, Pico W & CircuitPython](https://learn.adafruit.com/generating-text-with-chatgpt-pico-w-circuitpython.md)
- [File Glider](https://learn.adafruit.com/file-glider.md)
- [Circuit Playground-O-Phonor](https://learn.adafruit.com/circuit-playground-o-phonor.md)
- [Scratch 3 Walkthrough and Demo](https://learn.adafruit.com/guide-to-scratch-3.md)
- [How to Choose a Microcontroller](https://learn.adafruit.com/how-to-choose-a-microcontroller.md)
- [Lucky Cat with Circuit Playground Express](https://learn.adafruit.com/lucky-cat-with-circuit-playground-express.md)
