Habe mir einzel-LEDs besorgt, da ich nur eine LED brauche.
Weil ich nicht gleich Code kopieren wollte, ohne diesen zu verstehen, habe ich selbst mal etwas gespielt.
Auch wenn mein Code total außerhalb der Spezifikation und Timings liegt, funktioniert es mit einer LED zuverlässig.
Ich kann es mir selbst nicht erklären, zumal ich bei der NULL des Protokolls die 0,35us einfach missachte.
Alles anzeigen
Weil ich nicht gleich Code kopieren wollte, ohne diesen zu verstehen, habe ich selbst mal etwas gespielt.
Auch wenn mein Code total außerhalb der Spezifikation und Timings liegt, funktioniert es mit einer LED zuverlässig.
Ich kann es mir selbst nicht erklären, zumal ich bei der NULL des Protokolls die 0,35us einfach missachte.
Quellcode
- $regfile = "m328pdef.dat"
- $crystal = 16000000
- $hwstack = 32
- $swstack = 10
- $framesize = 40
- $baud = 19200
- Config Portc.0 = Output
- Dim I As Integer
- Dim S As Byte
- Dim Farbe As Byte
- Dim R As Byte
- Dim G As Byte
- Dim B As Byte
- Declare Sub Ws2812
- G = 0
- R = 0
- B = 0
- Do
- Farbe = 90
- Call Ws2812
- Loop
- Sub Ws2812
- R = Farbe
- B = 254 - Farbe
- Dim Ii As Integer
- For Ii = 8 To 1 Step -1
- If G.ii = 1 Then
- Portc.0 = 1
- Waitus 1
- Portc.0 = 0
- nop
- nop
- nop
- Else
- Portc.0 = 1
- nop
- nop
- nop
- Portc.0 = 0
- End If
- Next
- For Ii = 8 To 1 Step -1
- If R.ii = 1 Then
- Portc.0 = 1
- Waitus 1
- Portc.0 = 0
- nop
- nop
- nop
- Else
- Portc.0 = 1
- nop
- nop
- nop
- Portc.0 = 0
- End If
- Next
- For Ii = 8 To 1 Step -1
- If B.ii = 1 Then
- Portc.0 = 1
- Waitus 1
- Portc.0 = 0
- nop
- nop
- nop
- Else
- Portc.0 = 1
- nop
- nop
- nop
- Portc.0 = 0
- End If
- Next
- End Sub