177 views|0 replies

8

Posts

1

Resources
The OP
 

[2024 DigiKey Creative Competition] Part 2, Raspberry Pi drives 6+1 micArray LED lights [Copy link]

 

1. Introduction

One of the kits in this competition is Sipeed's 6+1MicArray microphone array, which is used to detect sound and display lights. It is the following:

The microphone array module is designed by Sipeed based on the MSM261S4030H0 digital microphone chip. The module has high sound recognition sensitivity and signal-to-noise ratio. It consists of six microphones along the board and one central microphone. The 12 LEDs on the array board can be used to visually identify the direction of the sound source and GCC-PHATrealize sound source positioning, speech recognition, beamforming and other demand occasions based on the algorithm. This peripheral is quite interesting. Today, I will drive the LED lamp beads and play with the cool atmosphere lights.
2. Wiring
The official website for the peripherals is:

Related Parameters #

Features parameter
Sound pressure level 140 dB SPL
Sensitivity -26(dB,dBFS [url=home.php?mod=space&uid=1013604]@1KHZ[/url] 1Pa)
Signal-to-Noise Ratio 57 dB (20kHz bandwidth,A-weighted)
THD<1% (100dB SPL @1kHz S=Nom,Rload>2k)
Clock frequency 1.0-4.0Mhz (normal mode)
150-800khz (low power mode)
MEMS Microphones 7 MSM261S4030H0 array
Connectors Support 2*5P 2.54mm terminal and 10P 0.5mm FPC connector
light 12 SK9822 LEDs form a circular LED array
Multiple LEDs can be cascaded via dual signal lines / 8 Bit (256 levels) adjustable color / 5 Bit (32 levels) brightness adjustment
size 78.1*88.8mm
After reading the introduction, I know that the LED lamp beads are SK9822, which is better than the common WS2812. The color is 24 bits in RGB format, which is very bright.
First, let's take a look at the wiring method and port introduction:
Pin number Pin Name type Pin Description
1 VIN VCC Module power input positive
2 GND GND Module power ground
3 MIC_D0 I/O Serial data output of IS interface for microphone 0 and microphone 1
4 MIC_D1 I/O Serial data output of IS interface for microphones 2 and 3
5 MIC_D2 I/O Serial data output of IS interface for microphones 4 and 5
6 MIC_D3 I/O Serial data output of the IS interface for the center microphone
7 MIC_WS I/O Serial data word selection for IS interface
8 MIC_CK I/O Serial data clock for the IS interface
9 LED_CK I/O Serial data clock for LEDs
10 LED_DA I/O Serial data output for LEDs

So use Dupont wire to connect to Raspberry Pi 5:

In my wiring, LED_CK and LED_DA are connected to pins 26 and 19 of BRCM, and VCC and GND are normally connected to 3.3V and GND.

3. Download the Python driver package

Python is used here to complete the LED drive display, mainly because Python programming is relatively simple, and there are many practical libraries available.

After searching, I found that there is an apa102-pi library that can be used. The address of the library is:

链接已隐藏,如需查看请登录或者注册

Article link: https://blog.csdn.net/gitblog_01171/article/details/142078725

Use Python to download the library: `pip install apa102-pi`

Since the official image python version is 3.11, the following error will appear:

So we need to create a python virtual environment:

root@raspberrypi:~# python3 -m venv my-virtual-environment
root@raspberrypi:~# python3 -m venv my-virtual-environment
``

Then use pip command to install apa102-pi library

After successful installation, you can start editing the demo code for testing

4. Write test demo code

The code is as follows:

#!/usr/bin/env python3
"""Ultra simple sample on how to use the library"""
from apa102_pi.driver import apa102
import time
import random

# 24位颜色值的常量定义
COLORS = [
    0xFF0000,  # COLOR_RED
    0x00FF00,  # COLOR_GREEN
    0x0000FF,  # COLOR_BLUE
    0xFFFF00,  # COLOR_YELLOW
    0x00FFFF,  # COLOR_CYAN
    0xFF00FF,  # COLOR_MAGENTA
    0xFFFFFF,  # COLOR_WHITE
    0x808080,  # COLOR_GRAY
    0xD3D3D3,  # COLOR_LIGHT_GRAY
    0x404040   # COLOR_DARK_GRAY
]


# 生成一个长度为240的列表,随机填充颜色值
random_colors = [random.choice(COLORS) for _ in range(240)]


def main():
    # Initialize the library and the strip. This defaults to SPI bus 0, order 'rgb' and a very low brightness
    strip = apa102.APA102(num_led=12, order='rgb', bus_method='bitbang',  mosi=19, sclk=26, ce=None,
                 bus_speed_hz=30000000, global_brightness=4)

    # Turn off all pixels (sometimes a few light up when the strip gets power)
    strip.clear_strip()

    # Prepare a few individual pixels
    for index,color in enumerate(random_colors):
        strip.set_pixel_rgb(index%12,color,bright_percent=index%4)

        strip.show()
        # Wait a few Seconds, to check the result
        time.sleep(0.1)
   

    # Clear the strip and shut down
    strip.clear_strip()
    strip.cleanup()


if __name__ == '__main__':
    main()

This code will generate a random color list, and then iterate through the list to form a non-stop chasing light effect. More light effects can be explored by yourself.

Run as:
(my-virtual-environment) root@raspberrypi:~# python led_light.py

At this time, an error will be reported:

After 2 hours of exploration, I found that the gpio library of rpi was too old. I found the cause and solution in this article: https://blog.csdn.net/qq_41918983/article/details/142111052

Then follow the tutorial to fix it:

Then you can continue running the program:

5. Summary

This article records how to use the Raspberry Pi to drive the LED lamp bead SK9822 on the 6+1 MicArray. There are some small pitfalls, but fortunately they have been solved. I hope it can help everyone.

This post is from DigiKey Technology Zone
 
 

Just looking around
Find a datasheet?

EEWorld Datasheet Technical Support

EEWorld
subscription
account

EEWorld
service
account

Automotive
development
circle

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京B2-20211791 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号
快速回复 返回顶部 Return list