Hallo Forum gemeinde und Bastler
ich suche eine Stufenbeleuchtung mit einen ATtiny2313 und für 6 stufen wahr es, kan mir jemand helfen
Mit Freundtlichen Grüßen
Code
Thorsten sch.
Ps: ich habe einen code von der schaltung aber irgendwie ist da ein wurm drin
$regfile = "attiny2313.dat"
$crystal = 8000000
$hwstack = 40
$swstack = 16
$framesize = 32
Ddrb = &B00111111
Ddrd = &B00001100
Portb = &B00000000
Portd = &B00110000
Config Timer1 = Timer , Prescale = 256
On Timer1 Timer1_isr
Const Timerload = 34285
Declare Sub Switch_on(byval Cstart As Byte , Byval Cstop As Byte , Byval Reverse As Byte)
Declare Sub Switch_off
Declare Sub Wait_and_keys
Dim Led As Byte , I As Byte , Backup As Byte
Dim Ison As Bit , Stayon As Bit
Dim Seconds As Integer , Ontime As Integer
If Pind.4 = 0 And Pind.5 = 0 Then
Ontime = 300
Elseif Pind.5 = 0 Then
Ontime = 180
Elseif Pind.4 = 0 Then
Ontime = 120
Else
Ontime = 0
End If
Ison = 0
Stayon = 0
Seconds = 0
Do
Debounce Pind.2 , 1 , Sw1 , Sub
Debounce Pind.3 , 1 , Sw2 , Sub
If Stayon = 0 And Seconds > Ontime Then Switch_off
Loop
End
Sub Switch_on(cstart , Cstop , Reverse)
Ison = 1
If Reverse = 0 Then
For Led = Cstart To Cstop
If Led = 2 And Pind.2 = 1 Then
Stayon = 1
Backup = Portb
Portb = 0
Waitms 200
Portb = Backup
End If
Portb.led = 1
Wait_and_keys
If Ison = 0 Then
Portb = 0
Exit For
End If
Next Led
Else
For Led = Cstart To Cstop Step -1
If Led = 3 And Pind.3 = 1 Then
Stayon = 1
Backup = Portb
Portb = 0
Waitms 200
Portb = Backup
End If
Portb.led = 1
Wait_and_keys
If Ison = 0 Then
Portb = 0
Exit For
End If
Next Led
End If
If Ontime > 0 And Stayon = 0 Then
Timer1 = Timerload
Enable Interrupts
Enable Timer1
End If
End Sub
Sub Switch_off
Ison = 0
Stayon = 0
Portb = 0
Disable Timer1
Disable Interrupts
Seconds = 0
End Sub
Sub Wait_and_keys
For I = 1 To 30
Debounce Pind.2 , 1 , Sw1 , Sub
Debounce Pind.3 , 1 , Sw2 , Sub
Waitms 20
Next I
End Sub
Timer1_isr:
Incr Seconds
Timer1 = Timerload
Return
Sw1:
If Ison = 0 Then
Call Switch_on(1 , 5 , 0)
Else
Call Switch_off
End If
Return
Sw2:
If Ison = 0 Then
Call Switch_on(5 , 0 , 1)
Else
Call Switch_off
End If
Return
Alles anzeigen