Rust Embassy Help

Hello! I am really new to Rust, especially in Embedded Rust with the Embassy framework. I have a project for university where I am building WS2812B led strip and a sound sensor. I tried all the crates I found, but nothing worked, especially for the LED strip. I was able to write the code I in MicroPython, but I want to use Rust. I am really desperate and I'd really need some help.

I am using a PICO W as a hardware.

Thank you for your attention!

The code:

from neopixel import Neopixel
import time


pix = Neopixel(8, 0, 0, "GRB")
mic = Pin(1, machine.Pin.IN, machine.Pin.PULL_DOWN)

c = 0

color_dict = {0:(255, 100, 0),
              1:(255,50,0),
              2:(0, 255, 0),
              3:(0,0,255),
              4:(255, 0, 0),
              5:(0, 255, 100),
              6:(255, 255,255)}

while True: 
    print(mic.value())
    if mic.value() == 1:
        pix.brightness(255)
        pix.fill(color_dict[0])    
        pix.show()
    else:
        pix.brightness(255)
        pix.fill((0,0,0))    
        pix.show()

Hi, and welcome to URLO! It would be highly appreciated if you could format your code instead of posting it as plain text, which makes it hard to read. You can find guidance on how to do so here:

1 Like

There is an example for driving the ws2812 on a Pico here: embassy/examples/rp/src/bin/pio_ws2812.rs at main · embassy-rs/embassy (github.com)

Is that what you are looking for?

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.