Deep Dive

Before moving forward, let's take a moment to more closely examine the code for this project and how it works.

This MakeCode example provides instructions for a 60 second countdown and provides visual & audible warnings at 30 seconds, 15 seconds, and 5 seconds. The code also allows the user to pause and restart the countdown whenever they need to. When the countdown hits 0 it beeps and flashes continually until it's tossed to the next speaker, at which point the countdown automatically restarts. 

Let's take a look at how each of these functions are coded in MakeCode.



In the green on start block there are a series of instructions for Circuit Playground Express to perform as soon as it's powered on.


Here you can set the length of the timer, adjust the sensitivity to being shaken, change the volume of the beeps, etc.


On startup, the board will show the rainbow animation for 1 second before illuminating two NeoPixel LEDs at their starting point, indicating it is ready.

Tick Tock


In this pink input block, there are some instructions telling the timer when and how to operate.


As you can see in the while statement, the slide switch must be slid right in order for the timer to start. Once this condition is met, pressing the A button will start the countdown.

This while statement also allows the user to pause the timer if necessary and restart it again right where it left off.

Flipping the slide switch to the left will pause the countdown.

Flipping the switch to the Right again primes the countdown, and pressing the A button starts it counting down again. 



In the green forever block are the instructions that are always running in the background, watching the countdown and waiting for it to hit certain numbers.


The blue if statement at the end of this block tells Circuit Playground Express to beep and flash red continually until it detects a shake.

Shake to Restart


In the on shake block there are instructions for how Circuit Playground Express should reset itself when it detects a sudden change in acceleration.

This guide was first published on Jan 05, 2019. It was last updated on Jan 05, 2019.

This page (Understanding the Code) was last updated on Dec 19, 2018.

Text editor powered by tinymce.