Introduction: Voice-Controlled NeoPixel Lights With Micro:Bit AI

About: Dr. Kadam Bhambari , is an Educator at SkoolofCode with Ph.D. and MTech in Electronics. She is an expert in Microbit, Arduino, and Artificial intelligence.

In this project,a voice-controlled Neopixel system is built using Micro:bit and AI. The Micro:bit is trained to recognize voice commands like "Red," "Green," and "Blue" through Teachable Machine and https://makeairobots.com/. Red command will turn ON the red lights of the Neopixel, the green voice command will turn ON green, and the Blue voice command will turn ON the Blue neopixels.

This project is an exciting way to explore AI, coding, and physical computing while building something fun and practical.

Supplies

Micro:bit V2 : https://www.amazon.com/KEYESTUDIO-Micro-Original-Microbit-Starter/dp/B0BP1J72RR/ref=sr_1_5?crid=24QN4TC4A7R3A&dib=eyJ2IjoiMSJ9.u5VUC1NKQSmzTQmyP5URcM_fy4VVSV117cwMxyO57FGgQ18YhvnYvu5busEr8fWZnz5mKGv42-0vwStQF7yAQH5Zgx2ft2CIJDW55JvAFr-Kko7W89xW8VsTd_-qxMj4-RxzP-zJOIoAGiuDyW7ERA97ewTbokw9hQuGOvgijsgF5IYRtVJ5LUmZvBQlVSWGBkZDdVSqV1LMzKXJkcHz33crzyJCCfT5XrzR9Rz_hm0.LhFcLizmvxzmnq1wqM-THnC4jtMYlvlygoRbobT8G_g&dib_tag=se&keywords=microbit&qid=1739417721&sprefix=microbit%2Caps%2C312&sr=8-5

Neopixels: https://www.amazon.com/SeeedStudio-Grove-Stick-WS2813-Mini/dp/B07Q1Y3DYY

Breakout Board: https://www.amazon.com/Iiunius-KittenBot-IOBIT-V2-0-Micro/dp/B0CB3VYKZX/ref=sr_1_1?crid=4D3A9P0OXL5W&dib=eyJ2IjoiMSJ9.pSwKokjvEAzR2DTz0cq0-eECqaFDG1cofw92jEuzI0sd-xisO4KlflwUoOlKbbKy4m1KTCVB8d1OwuBNBlR8uDTWG2daUihqJ-gbGPfAGOBDVEoXfQPjyeMp9PEeEdtXn8Quq8VOCMbbjS7mPEcFFYjRQspVKSNcd5qFeivj6mbzpPC5amIfVXA4iggxRaXZFsIKP-iIynwsU1J0GCTL1Y_7tT9Vnje9WPj6kMa-luU.UpLjFteaVWwFKVvVuQ-qsDDDuu_bAzOfVzbHQ02vbXs&dib_tag=se&keywords=KittenBot+IOBIT+V2.0+for+micro%3Abit&qid=1722182696&sprefix=kittenbot+iobit+v2.0+for+micro+bit%2Caps%2C134&sr=8-1

Jumper Cables: https://www.amazon.com/Elegoo-EL-CP-004-Multicolored-Breadboard-arduino/dp/B01EV70C78/ref=sr_1_1_sspa?crid=LMPAHM5ZMN4G&dib=eyJ2IjoiMSJ9.tjHxIQLJsk16_0YVtUGN6YDl_-VJ0RMBFAIsWPYBG2pMvW06Nb1z_CeoJXYjxmhObW6JmzThd_5E7ZBQtb54Ysn94JvBXm_qNf57GAUMct50xb1sUOQd-kvZBex0gef1LdL2Pftf4ZPHwA4LI8bl9Ddz4qhsP0FbDPaeOm-YUB6XMMJ6Jo9Bnfn44P3Nt9ht5Uwl2ein7g82S0BmjXD1zHZBJtkWBlE5oeCqn4uKF64.ZKrUkvqjGYAXbkf8griOLuorzzISRJvMRqBndO3hXAE&dib_tag=se&keywords=jumper+cables+arduino&qid=1729508574&sprefix=jumper+cables+ard%2Caps%2C556&sr=8-1-spons&sp_csd=d2lkZ2V0TmFtZT1zcF9hdGY&psc=1

Step 1: Micro:bit Interfacing With Neopixels

1: Prepare Components

  1. Insert the Micro:bit into the dedicated slot on the breakout board. Ensure it is firmly adjusted in the slot.
  2. Identify the NeoPixel’s four pins:
  3. GND (Ground)
  4. Vcc (Power input, 3V)
  5. SIG (Data signal input)
  6. NC (No connection; leave unconnected).

2 : Connect Power and Ground

  1. Ground (GND):
  2. Connect the NeoPixel’s GND pin to the breakout board’s GND terminal through the M to F jumper wire.
  3. Power (Vcc):
  4. Connect the NeoPixel’s Vcc pin to the breakout board’s 3V terminal through the M to F jumper wire.

3: Link the Data Signal


  1. Connect the NeoPixel’s SIG pin to the breakout board’s P0 (or any other pin can be used ) terminal through the M to F jumper wire.

4: Secure Connections

  1. Double-check all wiring:
  2. GND → Breakout GND (Black)
  3. Vcc → Breakout 3V (Red)
  4. SIG → Breakout P0 (Yellow/Green)
  5. NC remains unconnected.
  6. Ensure no loose wires or accidental short circuits.


Step 2: Teaching AI for Micro:bit

Creating an Audio Model

To build a voice-controlled Neopixel system using Micro:bit, we first need to train an AI model that recognizes voice commands.

1. Open the Make AI Robots Website

  1. Navigate to https://makeairobots.com/.

2. Enable Microphone Access

  1. Upon opening the website, allow microphone access when prompted. This is necessary to collect audio samples for training.

3. Open Google Teachable Machine

  1. Click on the Google Teachable Machine AI Model option on the Make AI Robots website.
  2. This will redirect you to Google Teachable Machine.

4. Create an Audio Model

  1. Click on "Audio Model" to start a new audio-based classification project.

5. Collect Training Data

  1. Create a background noise class by recording ambient noise to help the model distinguish voice commands from general noise.
  2. Add three new classes:
  3. Red (for controlling red Neopixels)
  4. Green (for controlling green Neopixels)
  5. Blue (for controlling blue Neopixels)
  6. Record multiple samples for each class by speaking the respective color name into the microphone.

6. Train the Model

  1. Click Train Model to allow the system to learn and classify the recorded audio data.

7. Test the Model

  1. After training, test the model by speaking the recorded commands and observing if it correctly identifies them.

8. Export the Model

  1. Click on Export Model and choose the cloud-hosted option to generate a link to the trained model.
  2. Upload the model to obtain the final ML model URL, which will be used in the next steps to integrate voice control with Micro:bit.


Step 3: Coding Micro:bit

Now that we have trained and exported the voice recognition model, the next step is to integrate it with Micro:bit using MakeCode.

1. Open the Starter Micro:bit Code

  1. Go to Make AI Robots.
  2. Click on Starter Micro:bit Code to open the MakeCode environment.

2. Edit the Code

  1. Click on "Edit Code" to make modifications to the existing program.

3. Install the Neopixel Extension

  1. In MakeCode, go to Extensions (found under the gear icon).
  2. Search for "Neopixel" and install the extension to control Neopixels with Micro:bit. Use blocks (as shown in the picture to control the neopixels)

4. Update Class Names

  1. Modify the existing code to match the class names from the trained AI model:
  2. Red
  3. Green
  4. Blue

This ensures that the Micro:bit correctly maps the voice commands to control Neopixels accordingly.

5. Download and Upload the Code to Micro:bit

  1. Once the code is updated, click on Download to save the .hex file.
  2. Connect your Micro:bit to your computer via USB and copy the downloaded file onto it.
  3. Wait for the Micro:bit to flash the new code.


Step 4: Connecting Micro:bit to AI

Now that the code is uploaded to the Micro:bit, the final step is to connect it with the AI model and test the voice-controlled Neopixels.

1. Connect Micro:bit to AI

  1. Open the Make AI Robots website.
  2. Click on "Connect Your Micro:bit to AI" to establish a connection between the Micro:bit and the trained AI model.

2. Select the Micro:bit Serial Port

  1. A pop-up will appear asking you to select a serial port.
  2. Choose mbed Serial Port from the available options.
  3. Click Connect and wait for the Micro:bit to establish communication.

3. Wait for the AI Model to Load

  1. Once connected, the audio model will take a few moments to load.
  2. Ensure your microphone is enabled so that the model can recognize voice commands.

4. Test Your Project

Once the model has loaded successfully, test the voice control functionality:

  1. Say "Red" → The red Neopixel should turn ON, and the Micro:bit LED display will show a heart icon.
  2. Say "Green" → The green Neopixel should turn ON, and the Micro:bit LED display will show smiley accordingly.
  3. Say "Blue" → The blue Neopixel should turn ON, and the LED display will change to show an icon for 7 number.

Your voice-controlled Neopixel system is now complete