3032 views|4 replies

28

Posts

1

Resources
The OP
 

8-bit full-color LED module with built-in ws2811 [Copy link]

 

Please ask the master:

How to delay 0.5us? Use time.sleep(0.0000005)?

Decimals cannot be used in time.sleep_us()

In C language, I see that others use __nop(), but there is no such function in Micropython? Of course, the delay is not accurate, and it will not work properly when controlling multiple LEDs.

Some people say to use SPI's DMA mode, but MciroPython doesn't seem to have it either?

How to control WS2811?

鎵规敞 2020-05-09 123306.png (255.38 KB, downloads: 0)

鎵规敞 2020-05-09 123306.png

Latest reply

Official routine from machine import Pin from neopixel import NeoPixel pin = Pin(0, Pin.OUT) # set GPIO0 to output to drive NeoPixels np = NeoPixel(pin, 8) # create NeoPixel driver on GPIO0 for 8 pixels np[0] = (255, 255, 255) # set the first pixel to white np.write() # write data to all pixels r, g, b = np[0] # get first pixel colour   Details Published on 2020-5-9 19:47
 
 

1w

Posts

25

Resources
2
 

In MicroPython, nrf/esp8266/esp32 has built-in WS2812 driver, which can be used directly through the NeoPixel library, and most GPIOs can be driven.

There is no direct integration in STM32, but there are programs on the Internet that drive the MOSI pin via SPI.

 
 
 

1w

Posts

25

Resources
3
 

Official routine

from machine import Pin
from neopixel import NeoPixel

pin = Pin(0, Pin.OUT)   # set GPIO0 to output to drive NeoPixels
np = NeoPixel(pin, 8)   # create NeoPixel driver on GPIO0 for 8 pixels
np[0] = (255, 255, 255) # set the first pixel to white
np.write()              # write data to all pixels
r, g, b = np[0]         # get first pixel colour

 
 
 

28

Posts

1

Resources
4
 

First of all, thank God.

I originally wanted to write the driver according to the timing of the official document, but I found that no matter how I wrote it, I could only turn on the light but not turn it off.

I searched many people's programs on Baidu, and everyone said that the delay could not be controlled, or that MicroPython could not achieve a delay below milliseconds.

In the spirit of perseverance, I studied the time of single-step execution.

I made a 1000-step loop, in which I did one operation (setting the level low), and the result was 9111 milliseconds, which means that each step took 9 milliseconds on average.

WS2811 cannot make a 0.5 millisecond delay, so all are made into 1 code, so the light is only on and never off.

So this path had to be abandoned.

 
 
 

28

Posts

1

Resources
5
 

I found a WS2812 driver and used the MOSI pin of SPI to send data, which can be perfectly controlled.

Thank you God.

 
 
 

Guess Your Favourite
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