Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

Fun with AI and swordfish basic

I have some tube lights with 300 leds for 50 watts but some only need one color red or blue the rest
do a wave of blue red green there 80 of tubes i used the esp 32 and wled for those
now back to making led tubes


 
Last edited:
here's a version of the SendByte() sub that would produce a lot better timing (based on that original AI code)

Code:
Sub SendByte(ByVal DataByte As Byte)
    dim i as byte
    
    For I = 0 To 7 ' Loop 8 times for 8 bits
        ' send bits msb to lsb
        If DataByte.bits(7) = 1 Then ' Send a '1' bit
            ' Send 1-bit (T1H: ~0.8us HIGH, T1L: ~0.45us LOW)
            ' T1H: 4 instruction cycles (0.8us)
            ' T1L: 2-3 instruction cycles (0.4-0.6us)
            WS2812BDataPin = 1
            NOP ' 200ns
            NOP ' 400ns
            NOP ' 600ns
            NOP ' 800ns (approx T1H)

            WS2812BDataPin = 0
            NOP ' 200ns
            NOP ' 400ns (approx T1L)
        Else ' Send a '0' bit
            ' Send 0-bit (T0H: ~0.4us HIGH, T0L: ~0.85us LOW)
            ' T0H: 2 instruction cycles (0.4us)
            ' T0L: 4-5 instruction cycles (0.8-1.0us)

            WS2812BDataPin = 1
            NOP ' 200ns
            NOP ' 400ns (approx T0H)

            WS2812BDataPin = 0
            NOP ' 200ns
            NOP ' 400ns
            NOP ' 600ns
            NOP ' 800ns (approx T0L)
            NOP ' 1000ns (Optional, for slightly longer T0L if needed)
        End If
        DataByte = DataByte << 1
    Next
End Sub

Timing is always going to be an issue with these, so something that uses hardware would be a lot better.
 

Latest threads

New Articles From Microcontroller Tips

Back
Top