Étape 1 : Fais-le
Qu'est-ce que c'est ?
Make the new micro:bit's microphone respond to claps and beats with an animated light show.
Introduction
Guide de codage
Ce que vous apprendrez
- How computers take inputs, process them using code and create different outputs
- How to use the new micro:bit's built-in microphone sensor to trigger events in your code
- That the micro:bit's microphone can be used to respond to both quiet and loud sounds
Comment ça marche
- When the microphone detects a loud sound, like a clap, it shows a large heart on the LED display.
- If it detects a quiet sound, for example after your clap has finished, it shows a small heart.
- The effect of this is to create a simple heart animation that responds to claps or strong beats in music.
Ce dont vous aurez besoin
- nouveau micro:bit avec son (ou simulateur MakeCode)
- MakeCode ou éditeur Python
- un boîtier de piles (optionnel)
Étape 2 : Codez
Étape 3 : Améliorez
- Create your own animation using other icons or drawing your own pictures.
- Make the micro:bit respond to a loud sound by making a sound of its own. Does this cause any problems? How can you fix them?
- You can change the sound level that triggers a loud sound event. This level is called a threshold. In MakeCode use the 'set loud sound threshold to...' input block to choose different sound levels to make it more or less sensitive to loud sounds.
- In Python, to change the threshold for loud sounds use
microphone.set_threshold(SoundEvent.LOUD, 128)
- changing the number 128 to the value you want between 0 and 255.