'ATtiny13 Sparrow_Soft_PWM
$regfile = "attiny13.dat"
$crystal = 1200000
$hwstack = 8
$swstack = 4
$framesize = 4
Config Portb = &B000011010
Dim T As Byte
Dim N As Byte
Dim M As Byte
Led1 Alias Portb.1
Led2 Alias Portb.3
S1 Alias Pinb.0
S2 Alias Pinb.2
Do
For N = 0 To 255
For T = 1 To 20
M = 255 - N
Led1 = 1 : Led2 = 0
Waitus M
Led1 = 0 : Led2 = 1
Waitus N
Next T
If S1 = 0 Or S2 = 0 Then Goto Handdimmer
Next N
Waitms 200
For M = 0 To 255
For T = 1 To 20
N = 255 - M
Led1 = 0 : Led2 = 1
Waitus N
Led1 = 1 : Led2 = 0
Waitus M
Next T
If S1 = 0 Or S2 = 0 Then Goto Handdimmer
Next M
Waitms 200
Loop
Handdimmer:
Do
For T = 1 To 20
M = 255 - N
Led2 = 0
If M > 0 Then Led1 = 1
Waitus M
Led1 = 0
If N > 0 Then Led2 = 1
Waitus N
Next T
If S2 = 0 Then
If N > 0 Then N = N - 1
End If
If S1 = 0 Then
If N < 255 Then N = N + 1
End If
Loop
End