This is a simple exercise, and one which we have found is perfectly understood in ages six and upwards. We have used this example in schools to help teach early concepts of “Algorithms”.
This is a simple task and one which takes only five minutes to setup, show the children and although it might seem simple to us, they are often amazed even by this relatively simple task.
Once this project is completed – we find it quite fun to have a volunteer try and set the sound alarm off. We find it works best, by getting the children to make the sound of a roaring lion (or other animal of their choice)! Starting off nice and quiet – and getting a lot louder…
The finished project in Microsoft MakeCode should look like this.
Breaking it down we have an “on loud sound” event. This is a great little event for explaining about “the ear” on the Circuit Playground Express. The children can liken it to other electronics they know of that “listen”. In a recent lesson we even had a response from one of the class…
“oh, you mean like Alexa in my Mum’s oven”
The lights on the Circuit Playground Express are great for engaging the children. Just the ability to easily set the lights on and off always seems to foster some amazed expressions. This block starts by simply turning all of the lights red and setting a brightness. Ours in the picture above is only set at 20, so you will want to experiment with that – those NeoPixels on the CPEX can really go quite bright!
Once the lights are on we want to turn them off again. We do that after a pause of 2 seconds (or 2000ms as us coders are more used to) and set the colour back to black.
Some next steps to try would be to go back to your project, have the children change the colour of the pixels, maybe add in an animation, or use the siren sound in the MUSIC section of MakeCode (and anything else you can think of).
Image Credits: [credit – Besjunior].