$regfile = "ATtiny2313.DAT" $crystal = 8000000 Ledpin Alias Portd.5 ' Pin:19 Config Ledpin = Output Dim Wr As Byte , Wg As Byte , Wb As Byte Dim I As Byte Do Wr = Rnd(255) Wg = Rnd(255) For I = 0 To 255 Step 2 Wb = I Gosub Ws2812 Waitms 20 Next I For I = 255 To 0 Step -2 Wb = I Gosub Ws2812 Waitms 5 Next I Loop Ws2812: 'ws2812 PORD.5 output Wr/Wg/Wb $asm lds R23,{Wg} rcall _b_out LDS R23,{Wr} rcall _b_out LDs R23,{Wb} rcall _b_out rcall _b_reset Return _b_out: ldi r16,8 _b_chk: rol R23 brcs _b_low _b_high: sbi portd,5 cbi portd,5 rjmp _b_nxt _b_low: sbi PORTD,5 nop nop nop nop cbi PORTD,5 nop nop nop nop rjmp _b_nxt _b_nxt: dec r16 brne _b_chk rol R23 ret _b_reset: ldi r16,$ff _w1: Dec R16 brne _w1 ret $end Asm Return