Skip to main content

Case 2: Visualized Sound

Introduction

Use the microphone of micro:bit to capture the sound loudness and the strength of micro:bit v2 analyzer to control the light ring through the jacdac cable. Press the "B" button on the motherboard to turn on the function; press the "A" button to turn off the function.


Case Purpose

  1. Understand the light ring and what RGB color is.

  2. Understand the light ring programming blocks in MakeCode.


Required Materials

ItemPictureQuantity
micro:bit V21
Jacdac expansion board1
Jacdac 10cm connection wire1
Light Ring1
USB Cable1

Sensor Principle Description

Principle description:

Light ring: a circular light ring composed of 8 RGB lights.


Connection diagram

As shown in the figure below, insert the micro:bit into the Jacdac expansion board and use the connecting wire to connect the light ring to the gold finger interface of the Jacdac expansion board.


Programming software

Microsoft Makecode


Makecode programming

Step 1: How to add Jacdac extension

  1. Enter Microsoft Makecode and click "New Project".

  1. In the pop-up window, enter a project name and click Create.

  1. Click "Extend" in the code drawer.

  1. In the pop-up interface, enter "Jacdac" and click the search icon, select the Jacdac software library, as shown in the figure.


Step 2:

  1. Connect micro:bit to the computer with a data cable.

    Note: If the micro:bit is running the Jacdac program for the first time, please pre-install a blank Jacdac program to the micro:bit, otherwise skip this step.

  1. Connect the sensor, MakeCode will automatically identify and simulate it, and the sensor will provide real-time feedback of the sensor status in the simulation area.

  1. Click on "ADD BLOCKS" sensor expansion module.

    Note: To connect a new sensor, repeat the "Click on "ADD BLOCKS" sensor expansion module" operation process.


Write the program as shown

---

https://makecode.microbit.org/_fqJ0EwTMFH12

You can also download the program directly from the following webpage, and start running the program after downloading.



Result

The microphone of micro:bit detects the ambient sound volume, and the LED light of the light ring will jump in a circle according to the volume of the sound. Press button A on the micro:bit to turn on the LED light, and press button B on the motherboard to turn off the LED light.

Thinking

What is the difference between decibel and frequency of sound?