Labs / MicroPython module projects

Audio Rhythm-Linked Light Effect Control Device (Based on GraftPort-RP2040 Development Board)(Open Version)

Author: Li Zisheng · Source: FreakStudio open documentation · License: CC BY 4.0

Contents
GraftPort-RP2040
GraftPort-RP2040

Project Description

1. Introduction

1.1 Project Background

This project is based on the GraftPort-RP2040 development board, and integrates an electret condenser microphone module based on the MAX9814 and an 8-segment bar digital tube module based on the PCF8574 chip to implement an integrated "audio energy acquisition and display" system. It incorporates the lightweight task scheduling and exception handling mechanisms of MicroPython to ensure stable system operation.

1.2 Overview of Main Functions of the Project

This project is developed based on MicroPython. Its core function is to collect audio signals in real time via an electret condenser microphone module based on the MAX9814, calculate audio energy through an audio frequency analyzer, and then display the audio energy level via an 8-segment bar LED module based on the PCF8574 chip; it supports on-board key interrupt to switch task start/stop, has built-in automatic garbage collection (GC) to avoid memory leaks, and is equipped with exception capture and rate-limited printing for convenient problem locating.

1.3 Applicable Scenarios or Application Area

2. Main Functions

3. Hardware Requirements

3.1 Hardware Required

This project is based on the GraftPort-RP2040 development board as the main controller:

v1.0 RP2040

Other required modules include:

MAX9814 PCF8574 SY7656 I2C

3.2 Hardware Connection

Electret condenser microphone module based on MAX9814: Connected via PH2.0 connecting cable to ADC0 interface (analog input)

MAX9814 PH2.0 ADC0 V1.0

8-segment bar digital tube module based on PCF8574 chip: connect to PH2.0 connector cable to access I2C0 interface;

PH2.0 I2C0 PCF8574

Lithium Battery Charge and Discharge Module: BAT interface connects to the lithium battery, and the OUT interface supplies power to the main control board via a PH2.0-2P connection cable.

PH2.0 2P RP2040
GraftPort-RP2040 PH2.0-2P MAX9814 PH2.0 ADC0 PCF8574 I2C0
v1.0 RP2040 MAX9814 PCF8574

3.3 Structural Assembly

First, use M3 plastic pillars to fix each module and the main control board to the bottom plate of the housing (M3 screw holes are pre-drilled on both the main control board and the housing):

M3 10 3.3
M3 GraftPort-RP2040

Next, secure the housing around its perimeter using M3 plastic pillars, then fasten M3 screws into the corresponding positions to complete the assembly:

M3 3.3

3.4 Notes

When the main control board is not connected to an external watchdog module, the RUN DIP switch 2 must be turned on:

2

The lithium battery charge-discharge module supports power level display, and you can charge it via the following Type-C interface:

Audio Rhythm-Linked Light Effect Control Device (Based on GraftPort-RP2040 Development Board)(Open Version)

4. Software Environment

5. File Structure

audio_responsive_light
├─ .flake8
├─ LICENSE
├─ README.md
├─ tools
│  ├─ dependency_analyzer.py
│  ├─ mpy_compiler.py
│  ├─ mpy_uploader.py
│  └─ README.md
├─ firmware
│  ├─ board.py
│  ├─ boot.py
│  ├─ conf.py
│  ├─ main.py
│  ├─ tasks
│  │  ├─ maintenance.py
│  │  ├─ sensor_task.py
│  │  └─ __init__.py
│  ├─ libs
│  │  ├─ __init__.py
│  │  ├─ TFT_mic
│  │  └─ scheduler
│  └─ drivers
│     ├─ __init__.py
│     ├─ pcf8574_led_driver
│     └─ max9814_mic_driver
└─ examples
   └─ README.md

6. Description of Key Documents

7. Core Idea of Software Design

driver_max4464_mic_driver.py v1.33.0

8. Instructions for Use

8.1 Hardware Connection

Connect the main control board, each sensor module and the battery according to the connection method specified in the "hardware requirements";

8.2 Run the Project (Using PyCharm + MicroPython Plugin)

Open PyCharm and install the corresponding MicroPython plugin.

1.45.20241

In the plugin, select Target Device (Target Device) as RP2040, and enable Auto-detect device path (Auto-detect device path).

Audio Rhythm-Linked Light Effect Control Device (Based on GraftPort-RP2040 Development Board)(Open Version)

Set Project/firmware as the project root directory.

Audio Rhythm-Linked Light Effect Control Device (Based on GraftPort-RP2040 Development Board)(Open Version)

Modify the runtime configuration:

Audio Rhythm-Linked Light Effect Control Device (Based on GraftPort-RP2040 Development Board)(Open Version)

Click the IDE green triangle button in the upper right corner to run, and you can start uploading the firmware and executing the project.

8.3

8.3 Modification of Running Configuration

You can configure conf.py to modify or add parameters as needed, for example:

# conf.py example configuration
ENABLE_DEBUG = True            # Whether to enable debug printing
AUTO_START = True              # Whether to run tasks automatically at startup

8.4 Functional Testing

Audio energy detection: emit sounds of different intensities near the microphone and observe LED strip light display to see if it changes accordingly;

Button Switch: Press the onboard button to pause the task (stop Data Acquisition and display update), and press it again to resume.

The terminal output is as follows:

GraftPort-RP2040 I2C 1 0x20 100000 1.0

8.5 Debugging and Problem Localization

9. Sample Program

There are no other reference sample codes for this project, you can directly firmware make modifications in the folder.

10. Notes

11. Version Record

12. Contact the Developer

If you have any questions or need assistance, please contact the developer via the following channels :
📧 Email: 10696531183@qq.com
💻 GitHub: https://github.com/FreakStudioCN

13. Licensing Agreement

In this project, except for machine and other MicroPython official modules (under the MIT license), all driver and extension codes written by the author are released under the Creative Commons Attribution-NonCommercial 4.0 International (CC BY-NC 4.0) Licensing Agreement.

You are free to:

Only the following conditions shall be complied with:

Copyright belongs to FreakStudio.

Appendix I: Project Source Code Download

https://github.com/FreakStudioCN/GraftPort_MicroPython_Labs/tree/main/audio_responsive_light

Appendix II: Hardware Module Reference Materials

GraftSense - Electret Condenser Microphone Module Based on MAX9814

GraftSense - An 8-segment Light Bar Digital Tube Module Based on the PCF8574 Chip

GraftSense-SY7656 Lithium Battery Charge-Discharge Module

GraftPort - Raspberry Pi Pico Expansion Board (Open Edition Template Files)

Version Record

Document Version

Date of Modification

Modifier

Modified Content

V1.0.0

2025-11-03

Hou Junhan

Draft the initial version of the document.

V1.1.0

2026-01-04

Li Zisheng

Final version.