Ok so i got this rgb led
that has four pins: VDD,VSS,DATA IN and DATA OUT
I understand that certain manipulation of voltage flow or frequency
has to be applied at DATA IN to get the desired light
I'm very horrible in understanding datasheets
Has anybody ever used this type of led before ?
how can i get the micropython to drive this led
There is this instruction in the datasheet but i can't figure out
where to start.
Data transfer time( TH+TL=1.25 μs ±600n s )
T0H 0 code ,high voltage time 0.4us ±150ns
T1H 1 code ,high voltage time 0.8us ±150ns
T0L 0 code , low voltage time 0.85us ±150ns
T1L 1 code ,low voltage time 0.45us ±150ns
https://abra-electronics.com/opto-illum ... of-10.html
below the page, in the attachments there is the datasheet
addressing(driving/controlling) RGB led with Micropython
Re: addressing(driving/controlling) RGB led with Micropython
Hi yolo,
That RGB LED you've linked to is a WS2812 which are also known by the marketing name that Adafruit gave them, "Neopixel".
You didn't mention which board you're using but some of the Micropython ports (at least the ESP8266, micro:bit) have out-of-the-box support for Neopixels.
Wiring is straightforward as they are controlled with a one-wire protocol. They are 5V devices - so connect a 5V supply to VDD, GND to VSS - but can be controlled from 3.3V GPIO lines. So connect a GPIO to DATA IN.
They are intended to be chained together by connecting DATA OUT to the DATA IN of the next Neopixel. You can leave the last one unterminated.
The documentation of the Neopixel module's make it pretty clear about how to control them but a short snippet would look like:
The Neopixel modules differ slightly between ports, for example that code works on an ESP8266 but np.write() would need to be change to np.show() on a micro:bit.
BTW it's difficult to have an implementation that works on all ports because the Neopixels are quite sensitive to timing and so a custom C library is typically written for the specific micro to carefully drive the required protocol.
Hope that helps!
That RGB LED you've linked to is a WS2812 which are also known by the marketing name that Adafruit gave them, "Neopixel".
You didn't mention which board you're using but some of the Micropython ports (at least the ESP8266, micro:bit) have out-of-the-box support for Neopixels.
Wiring is straightforward as they are controlled with a one-wire protocol. They are 5V devices - so connect a 5V supply to VDD, GND to VSS - but can be controlled from 3.3V GPIO lines. So connect a GPIO to DATA IN.
They are intended to be chained together by connecting DATA OUT to the DATA IN of the next Neopixel. You can leave the last one unterminated.
The documentation of the Neopixel module's make it pretty clear about how to control them but a short snippet would look like:
Code: Select all
>>> import machine, neopixel
>>> np = neopixel.NeoPixel(machine.Pin(4), 1) # GPIO 4, 1 Neopixel in the chain
>>> np[0] = (0, 128, 0) # Set the first Neopixel to green, half brightness
>>> np.write()
BTW it's difficult to have an implementation that works on all ports because the Neopixels are quite sensitive to timing and so a custom C library is typically written for the specific micro to carefully drive the required protocol.
Hope that helps!