Mini Project Lightbar Sources

 

'-------------------------------------------------------------------------------
'name : ATtiny13-Lightbar.bas
'copyright : Meeps & Parts - D.J. Oosterveld
'purpose : Lightbar with 4 patterns
'micro : ATtiny13
'-------------------------------------------------------------------------------

$regfile="attiny13.dat"
$crystal= 1200000
$hwstack= 32
$swstack= 8
$framesize= 16

Dim Program AsInteger
Dim Count AsInteger
Dim Flash AsInteger

Ddrb=&B00001111
Portb=&B00001111

ConfigPinb.4 =Input
Portb.4 = 1

Program = 1

Do
DebouncePinb.4 , 0 , Buttonsub ,Sub

SelectCase Program
Case 1:' Triple Split
For Flash = 1 To 3
Portb=&B00011100
Waitms 75
Portb=&B00011111
Waitms 75
Next Flash
Waitms 150
For Flash = 1 To 3
Portb=&B00010011
Waitms 75
Portb=&B00011111
Waitms 75
Next Flash
Waitms 150
Case 2:' Triple All
For Flash = 1 To 3
Portb=&B00010000
Waitms 75
Portb=&B00011111
Waitms 75
Next Flash
Waitms 200
Case 3:' Triple Outside-In
For Flash = 1 To 3
Portb=&B00010110
Waitms 75
Portb=&B00011111
Waitms 75
Next Flash
Waitms 150
For Flash = 1 To 3
Portb=&B00011001
Waitms 75
Portb=&B00011111
Waitms 75
Next Flash
Waitms 150
Case 4:' Triple H/L Split
For Count = 1 To 4
For Flash = 1 To 3
Portb=&B00011100
Waitms 75
Portb=&B00011111
Waitms 75
Next Flash
Waitms 150
For Flash = 1 To 3
Portb=&B00010011
Waitms 75
Portb=&B00011111
Waitms 75
Next Flash
Waitms 150
Next Count
For Count = 1 To 8
For Flash = 1 To 3
Portb=&B00011100
Waitms 35
Portb=&B00011111
Waitms 40
Next Flash
Waitms 75
For Flash = 1 To 3
Portb=&B00010011
Waitms 35
Portb=&B00011111
Waitms 40
Next Flash
Waitms 75
Next Count
EndSelect
Loop
End

Buttonsub:
Program = Program + 1
If Program = 5 Then
Program = 1
EndIf
Return