$regfile = "m32def.dat"
$crystal = 8000000 '3Mhz statt 8Mhz demnach müsste alles doppelt so schnell laufen
$hwstack = 100
$swstack = 100
$framesize = 100
'$sim
'Programmversionen ab RGB Umbau
'Änderungshistorie:
'V2.00 2016-03-30 Veränderung der PWM Frequenz wegen Interferrenzen mit dem RGM Modul
'V2.01 2016-03-30 Neuprogrammierung des Sterneneffektes, da die PWMfrequenz auf 2khz gesetzt werden musste
'V2.02 2016-04-01 Neuprogrammierung des Sterneneffektes, da die PWMfrequenz auf 4khz gesetzt werden musste
'V2.03 2016-04-04 Überarbeitung Sterneneffekt (Reduzierung Programmschritte)
'V2.04 2016-04-05 Überarbeitung Sterneneffekt (Reduzierung Programmschritte)
'V2.05 2016-04-07 Überarbeitung Sterneneffekt (Reduzierung Programmschritte)
'V2.06 2016-04-10 Merkerled funktionierte nicht
'V2.07 2016-04-19 Flimmert immer noch - neue Programmstruktur Modus 10
'V2.08 2016-05-03 kein sauberes Dimmen der ZufallsLED, Daher nochmal Modus 10 überarbeitet auf Geschwindigkeit
'V2.09 2016-12-06 Geschwindigkeit des Nachtbetriebes angpasst an Winter (Wintererkennung durch unlöschbare Variable)
'V2.10 2017-07-01 Verbesserungen da RGB Stripes öfter ausfallen (meist blau)
'V2.11 2017-07-03 Verbesserungen da RGB Stripes öfter ausfallen (meist blau)
'V2.12 2017-07-06 Verbesserungen da RGB Stripes öfter ausfallen (meist blau)Incr statt +1 wegen schneller
'V2.14 2018-06-07 Verbesserungen da RGB Stripes immer noch öfter ausfallen Sterneneffekt gelöscht
'*********************************************************************************************************
'Alle Ports auf digital 5V/0V setzen ausser die Eingänge der Bewegungsmelder die auf 2,6V
Ddra = &B11111111
Ddrb = &B11111111
Ddrc = &B11111111
Ddrd = &B00111111
'Alle Ports auf 0 setzen für definierten Anfangszustand
Porta = &B00000000
Portb = &B00000000
Portc = &B00000000
Portd = &B00000000
'Variablen und Subs festlegen
Declare Sub Switch_on(byval Cstart As Byte , Byval Cstop As Integer , Byval Reverse As Byte)
Declare Sub Switch_on1(byval Cstart As Integer , Byval Cstop As Integer , Byval Reverse As Byte)
Declare Sub Outputs
Declare Sub Outputgruppe
Declare Sub Movinglight(byval Reverse As Byte)
Declare Sub Doublemovinglight(byval Cstart As Byte , Byval Cstop As Integer , Byval Reverse As Byte)
Declare Sub Doublemovinglight2(byval Cstart As Byte , Byval Cstop As Integer , Byval Reverse As Byte)
Declare Sub Welle
Declare Sub Dimmen
Declare Sub Dimmschleife
Declare Sub Sterneneffekt
Dim Ison As Bit
Dim Isoff As Bit
Dim S1 As Bit
Dim S2 As Bit
Dim S3 As Byte
Dim Wert As Bit
Dim A As Bit
Dim B As Bit
Dim C As Bit
Dim Led As Integer
Dim Leu As Integer
Dim Leda As Byte
Dim Ledb As Byte
Dim Ledc As Byte
Dim Ledd As Byte
Dim Dauer As Byte
Dim Zwei As Byte
Dim Pwmhell As Word
Dim Pwmdunkel As Word
Dim Dimm As Word
Dim Timeout As Word
Dim Faktor As Single
Dim Pwmhell0 As Single
Dim Pwmhell1 As Integer
Dim Pwmhell2 As Integer
Dim Pwmdunkel0 As Single
Dim Pwmdunkel1 As Integer
Dim Pwmdunkel2 As Integer
Dim Speedmodus1 As Word
Dim Speedmodus2 As Word
Dim Speedmodus3 As Word
Dim Speedmodus4 As Word
Dim Speedmodus5 As Word
Dim Anzahlmodus4 As Word
Dim Speedmodus6 As Word
Dim Speedmodus7 As Word
Dim Anzahlmodus7 As Word
Dim Speedmodus10 As Word
Dim Speedmodus10_ As Word
Dim Z As Byte
Dim Y As Word
Dim X As Word
Dim W As Byte
Dim Modus As Byte
Dim Merkerdimmung As Bit
Dim Merkerpwmdunkel As Word
Dim Merkerpwmhell As Word
Dim Merkerled As Byte
Dim Merker1 As Single
Dim Merker2 As Single
Dim Merker3 As Bit
Dim Zaehler1 As Integer
Dim Zaehler2 As Byte
Dim Timeron As Long
Dim Timeron1 As Long
Dim Faktortimer As Single
Dim Winter As Long
Dim Winterx As Eram Long 'Winterzeit
'Winterx = Winter write to EEPROM
'Winter = Winterx read from EEPROM
Dim Portnra As Byte
Dim Portnrb As Byte
Dim Portnrc As Byte
Dim Portnrd As Byte
' Übersicht Speicherbereiche Variablen
'Dim as Bit = 0 bis 1
'Dim as Byte = 0 bis 255
'Dim as Integer = -32768 bis +32767
'Dim as Word = 0 bis 65535
'Dim as Long = -2147483648 bis 2147483647
'Dim as Single = 1,5 x 10^-45 bis 3,4 x 10^38
'Dim as Double = 5,0 x 10^-324 bis 1,7 x 10^308
'Dim as String = 254 Zeichen
'Variablen für LED Zustand (an oder aus) definieren
Ison = 0
Isoff = 1
Timeron = 0
Modus = Rnd(7) + 1
'Warte 25s Bis Sich Bewegungsmelder beruhigt Haben
'In dieser Zeit kann man die Sommer oder Winterzeit einstellen
Zaehler1 = 0
Winter = Winterx 'read from EEPROM
Do
'Wenn in der ersten 5s der Funkschalter aktiv ist, dann setze Winterzeit
If Pind.5 = 1 And Zaehler1 < 5000 Then
Winter = 4000000
Porta.1 = 1
End If
'Wenn in der nach 10s für 5s der Funkschalter aktiv ist, dann setze Sommerzeit
If Pind.5 = 1 And Zaehler1 > 10000 And Zaehler1 < 15000 Or Winter = 0 Then
Winter = 2000000
Porta.1 = 1
Porta.2 = 1
End If
Waitms 1
Zaehler1 = Zaehler1 + 1
Loop Until Zaehler1 = 25000
Zaehler1 = 0
Merkerdimmung = 0
'Wenn Merker "Winter" sich geändert hat, dann EEPROM Variable neu schreiben
If Winter <> Winterx Then Winterx = Winter
Porta = 0
'===========================================================================================
'===========================================================================================
'Programmanfang
Anfang:
'Geschwindigkeiten und Zeiten aller Modi festlegen (*µs)
Speedmodus1 = 500
Speedmodus2 = 200
Speedmodus3 = 230
Speedmodus4 = 120
Anzahlmodus4 = 180
Speedmodus5 = 300
Speedmodus6 = 250
Speedmodus7 = 1000
Anzahlmodus7 = 10
Speedmodus10 = 249
Speedmodus10_ = 1
Timeout = 0
Dauer = 100
'Zufallsgenerator für Auswahl Modus für Bewegungsmelder wenn LED aus
If Ison = 0 Then
Modus = Modus + 1
If Modus = 9 Then
Modus = 1
End If 'Rnd(7) + 1
End If
Anfangausdimmung:
'Warten damit Funk wieder ein falls manuell gedimmt werden sollte
Do
'Zählervariablen zurücksetzen
Led = 0
Ledb = 0
Ledc = 0
Ledd = 0
Z = 0
Y = 0
X = 0
W = 0
Pwmdunkel = 0
Pwmhell = 0
Timeron = Timeron + 1 'Timer 100ms x Timeron
If Timeron >= 36000 And Merkerdimmung = 0 And Pind.5 = 0 Then
Merkerdimmung = 1
Merkerpwmhell = 60
Merkerpwmdunkel = 190
Merkerled = 28
Goto Modus10
End If
'Abfrageschleife der Bewegungsmelder mit Abschalttimer
If Pind.7 = 1 And Pind.5 = 0 And Pind.6 = 0 And Ison = 0 Then
Goto Sw1
Elseif Pind.6 = 1 And Pind.7 = 0 And Pind.5 = 0 And Ison = 0 Then
Goto Sw2
Elseif Pind.5 = 1 And Pind.7 = 0 And Pind.6 = 0 And Ison = 0 Then
Goto Sw3
Elseif Pind.5 = 1 And Pind.7 = 0 And Pind.6 = 0 And S3 >= 1 Then
Goto Sw3
Elseif Pind.5 = 0 And Pind.7 = 0 And Pind.6 = 0 And Merkerdimmung = 1 And Ison = 0 Then
Goto Modus10
End If
'Timerende prüft in welcher Richtung die Beleuchtung losgelaufen ist um in umgekehrter Richtung auszuschalten
If Timeout >= Dauer And S1 = 1 And S2 = 0 And Ison = 1 Then
Goto Sw2
End If
If Timeout >= Dauer And S2 = 1 And S1 = 0 And Ison = 1 Then
Goto Sw1
End If
'Reset Timer und Speichervar. für Bewegungsmelder
If Timeout >= Dauer Then
Timeout = 0
S1 = 0
S2 = 0
End If
'Timer
Timeout = Timeout + 1
Led = 0
Waitms 100
Loop
End
Sw1:
'Bewegungsmelder 1 wurde dedektiert und startet anhand Ison, ob aus oder eingedimmt werdern soll
If S1 = 1 Or S3 = 1 Then
Goto Anfang
End If
'Modus 1
If Ison = 0 And Modus = 1 Then
Ison = 1
Isoff = 0
S1 = 1
Call Switch_on(0 , 28 , 0)
Elseif Ison = 1 And Modus = 1 Then
Ison = 0
Isoff = 1
S1 = 0
S2 = 0
Call Switch_on(0 , 28 , 1)
End If
'Modus 2
If Ison = 0 And Modus = 2 Then
Ison = 0
Isoff = 1
Speedmodus1 = Speedmodus2
Call Switch_on(0 , 28 , 0)
End If
'Modus 3
If Ison = 0 And Modus = 3 Then
Ison = 0
Isoff = 1
Call Switch_on1(0 , 33 , 0)
End If
'Modus 4
If Ison = 0 And Modus = 4 Then
Call Movinglight(0)
End If
'Modus 5
If Ison = 0 And Modus = 5 Then
Call Doublemovinglight(0 , 14 , 0)
End If
'Modus 6
If Ison = 0 And Modus = 6 Then
Call Doublemovinglight2(0 , 14 , 0)
End If
'Modus 7
If Ison = 0 And Modus = 7 Then
Call Welle
End If
Goto Anfang
Sw2:
'Bewegungsmelder 2 wurde dedektiert und startet anhand Ison, ob aus oder rückwärts eingedimmt werdern soll
If S2 = 1 Or S3 = 1 Then
Goto Anfang
End If
'Modus 1
If Ison = 0 And Modus = 1 Then
Ison = 1
Isoff = 0
S2 = 1
Call Switch_on(0 , 28 , 1)
Elseif Ison = 1 And Modus = 1 Then
Ison = 0
Isoff = 1
S1 = 0
S2 = 0
Call Switch_on(0 , 28 , 0)
End If
'Modus 2
If Ison = 0 And Modus = 2 Then
Ison = 0
Isoff = 1
Speedmodus1 = Speedmodus2
Call Switch_on(0 , 28 , 1)
End If
'Modus 3
If Ison = 0 And Modus = 3 Then
Ison = 0
Isoff = 1
Call Switch_on1(0 , 33 , 1)
End If
'Modus 4
If Ison = 0 And Modus = 4 Then
Call Movinglight(1)
End If
'Modus 5
If Ison = 0 And Modus = 5 Then
Call Doublemovinglight(0 , 14 , 1)
End If
'Modus 6
If Ison = 0 And Modus = 6 Then
Call Doublemovinglight2(0 , 14 , 1)
End If
'Modus 7
If Ison = 0 And Modus = 7 Then
Call Welle
End If
Goto Anfang
Sw3:
'Funk ein alles andere aus und von hinten beginnend einschalten
If S3 = 0 Then
S3 = 1
Porta = 0
Portb = 0
Portc = 0
Portd = 0
S3 = 1
Ison = 1
Isoff = 0
Call Switch_on(0 , 28 , 0)
Else
'Wenn Funk Schon mal an war gehe zur Dimmung
Goto Modus10
End If
Goto Anfang
'######################################################################
'Modus 1 und 2 für vorwärts oder rückwärts ein oder aus dimmen (mit anbleiben und ohne)
Sub Switch_on(cstart , Cstop , Reverse)
X = 0
Y = 0
W = 0
Nochmal:
If Reverse = 0 Then
Led = Cstart
Else
Led = Cstop
End If
W = Cstart
X = Cstop
X = X + 1
For Z = Cstart To Cstop
'Lege Tastverhältnis für PWM fest
Pwmdunkel = Speedmodus1 + 1
Pwmhell = 1
'Schleife für Dimmung eines LED Stripe
For Dimm = Speedmodus1 To 0 Step -1
Wert = Isoff
If S3 = 1 And Led < 6 Then
Leu = 5 - Led
Else
Leu = Led
End If
Call Outputs
Waitus Pwmdunkel
Wert = Ison
If S3 = 1 And Led < 6 Then
Leu = 5 - Led
Else
Leu = Led
End If
If Speedmodus1 = Speedmodus1 Then
Call Outputs
End If
Waitus Pwmhell
Pwmdunkel = Pwmdunkel - 1
Pwmhell = Pwmhell + 1
Next Dimm
If Speedmodus1 = Speedmodus2 Then
Call Outputs
End If
If Reverse = 0 Then
Led = Led + 1
Else
Led = Led - 1
End If
If Pind.5 = 1 And Led = -1 Then
Ison = 0
Isoff = 1
S3 = 0
Exit Sub
End If
If Pind.5 = 1 And Led = 29 And S3 = 1 Then
Goto Modus10
End If
If Pind.5 = 0 And S3 = 1 Then
Goto Anfang
End If
Next Z
Y = Y + 1
If Z = X And Y < 15 And Modus = 2 Then
Cstart = W
Goto Nochmal
End If
End Sub
Goto Anfang
'######################################################################
'Modus 3 für vorwärts oder rückwärts wischen wie Landebahn mit mehreren LEDs
Sub Switch_on1(cstart , Cstop , Reverse)
Wiederholung:
If Reverse = 0 Then
Led = Cstart
Else
Led = Cstop - 5
End If
W = Cstart
X = Cstop
X = X + 1
For Z = Cstart To Cstop
'Lege Tastverhältnis für PWM fest
Pwmdunkel = Speedmodus3 + 1
Pwmhell = 1
'Schleife für Dimmung eines LED Stripe
For Dimm = Speedmodus3 To 0 Step -1
Wert = Isoff
Leu = Led
Call Outputs
If Led >= 5 And Reverse = 0 Then
Wert = Isoff
Leu = Led - 5
Call Outputs
Elseif Led < 24 And Reverse = 1 Then
Wert = Isoff
Leu = Led + 5
Call Outputs
End If
Waitus Pwmdunkel
Wert = Ison
Leu = Led
'Call Outputs
If Led >= 5 And Reverse = 0 Then
Wert = Ison
Leu = Led - 5
'Call Outputs
Elseif Led < 24 And Reverse = 1 Then
Wert = Ison
Leu = Led + 5
'Call Outputs
End If
Waitus Pwmhell
Pwmdunkel = Pwmdunkel - 1
Pwmhell = Pwmhell + 1
Next Dimm
Porta = 0
Portb = 0
Portc = 0
Portd = 0
If Reverse = 0 Then
Led = Led + 1
Else
Led = Led - 1
End If
Next Z
Y = Y + 1
If Z = X And Y < 15 And Modus = 3 Then
Cstart = W
Goto Wiederholung
End If
End Sub
Goto Anfang
'######################################################################
'Modus 4 für vorwärts oder rückwärts Lauflicht mit drei LED
Sub Movinglight
For Z = 1 To Anzahlmodus4
Y = Y + 1
If Y = 1 And Reverse = 0 Then
A = 1
B = 0
C = 0
Elseif Y = 1 And Reverse = 1 Then
C = 1
B = 0
A = 0
End If
If Y = 2 Then
A = 0
B = 1
C = 0
End If
If Y = 3 And Reverse = 0 Then
A = 0
B = 0
C = 1
Y = 0
Elseif Y = 3 And Reverse = 1 Then
C = 0
B = 0
A = 1
Y = 0
End If
'beim letzen Durchlauf alle auschalten
If Z = Anzahlmodus4 Then
A = 0
B = 0
C = 0
End If
Porta.0 = A
Porta.1 = B
Porta.2 = C
Porta.3 = A
Porta.4 = B
Porta.5 = C
Porta.6 = A
Porta.7 = B
Portb.0 = C
Portb.1 = A
Portb.2 = B
Portb.3 = C
Portb.4 = A
Portb.5 = B
Portb.6 = C
Portb.7 = A
Portc.0 = B
Portc.1 = C
Portc.2 = A
Portc.3 = B
Portc.4 = C
Portc.5 = A
Portc.6 = B
Portc.7 = C
Portd.0 = A
Portd.1 = B
Portd.2 = C
Portd.3 = A
Portd.4 = B
Waitms Speedmodus4
Next Z
End Sub
Goto Anfang
'######################################################################
'Modus 5 für in beide Richtungen wischen von Mitte aus
Sub Doublemovinglight(cstart , Cstop , Reverse)
Wiederholung1:
If Reverse = 0 Then
Led = Cstart
Else
Led = Cstop
End If
W = Cstart
X = Cstop
X = X + 1
For Z = Cstart To Cstop
'Lege Tastverhältnis für PWM fest
Pwmdunkel = Speedmodus5 + 1
Pwmhell = 1
'Schleife für Dimmung eines LED Stripe
For Dimm = Speedmodus5 To 0 Step -1
Wert = Isoff
Leu = Led
Call Outputs
If Reverse = 0 Then
Leu = Z + 14
Else
Leu = 28 - Z
End If
Call Outputs
Waitus Pwmdunkel
Wert = Ison
Leu = Led
'Call Outputs
If Reverse = 0 Then
Leu = Z + 14
Else
Leu = 28 - Z
End If
'Call Outputs
Waitus Pwmhell
Pwmdunkel = Pwmdunkel - 1
Pwmhell = Pwmhell + 1
Next Dimm
Porta = 0
Portb = 0
Portc = 0
Portd = 0
If Reverse = 0 Then
Led = Led + 1
Else
Led = Led - 1
End If
Next Z
Y = Y + 1
If Z = X And Y < 15 And Modus = 5 Then
Cstart = W
Goto Wiederholung1
End If
End Sub
Goto Anfang
'######################################################################
'Modus 6 für in beide Richtungen wischen von Mitte aus aber wie Knight Rider
Sub Doublemovinglight2(cstart , Cstop , Reverse)
Wiederholung2:
If Reverse = 0 Then
Led = Cstart
Else
Led = Cstop
End If
W = Cstart
X = Cstop
X = X + 1
For Z = Cstart To Cstop
'Lege Tastverhältnis für PWM fest
Pwmdunkel = Speedmodus6 + 1
Pwmhell = 1
'Schleife für Dimmung eines LED Stripe
For Dimm = Speedmodus6 To 0 Step -1
Wert = Isoff
Leu = Led
Call Outputs
If Reverse = 0 Then
Leu = Z + 14
Else
Leu = 28 - Z
End If
Call Outputs
Waitus Pwmdunkel
Wert = Ison
Leu = Led
'Call Outputs
If Reverse = 0 Then
Leu = Z + 14
Else
Leu = 28 - Z
End If
'Call Outputs
Waitus Pwmhell
Pwmdunkel = Pwmdunkel - 1
Pwmhell = Pwmhell + 1
Next Dimm
Porta = 0
Portb = 0
Portc = 0
Portd = 0
If Reverse = 0 Then
Led = Led + 1
Else
Led = Led - 1
End If
Next Z
Y = Y + 1
If Z = X And Y < 15 And Modus = 6 And Reverse = 0 Then
Reverse = 1
Cstart = W
Goto Wiederholung2
Elseif Z = X And Y < 15 And Modus = 6 And Reverse = 1 Then
Reverse = 0
Cstart = W
Goto Wiederholung2
End If
End Sub
Goto Anfang
'######################################################################
'Modus 7 an- und abschwellend
Sub Welle
Pwmdunkel = Speedmodus7
Merker3 = 0
Speedmodus7 = Speedmodus7 * 2
For X = 1 To Anzahlmodus7
For Y = 1 To Speedmodus7
If Merker3 = 0 Then
Pwmhell = Pwmhell + 1
Pwmdunkel = Pwmdunkel - 1
Else
Pwmhell = Pwmhell - 1
Pwmdunkel = Pwmdunkel + 1
End If
Porta = 255
Portb = 255
Portc = 255
Portd = 63
Waitus Pwmhell
Porta = 0
Portb = 0
Portc = 0
Portd = 0
Waitus Pwmdunkel
If Pwmdunkel < 2 Then
Merker3 = 1
End If
If Pwmhell < 20 Then
Merker3 = 0
End If
Next Y
Next X
End Sub
Goto Anfang
'######################################################################
'Modus 10 alle bereits leuchtenden LED dimmen
Modus10:
'Tastverhältnis und letzte angesteuerte LED an Variable übergeben und S2 auf Modus 2 setzen
'Test:
S3 = 2
If Merkerdimmung = 1 Then
Pwmdunkel0 = Merkerpwmdunkel
Pwmhell0 = Merkerpwmhell
Pwmdunkel = Merkerpwmdunkel
Pwmhell = Merkerpwmhell
Pwmdunkel1 = 1
Pwmdunkel2 = Merkerpwmdunkel
Led = Merkerled
Ison = 1
Isoff = 0
Merkerdimmung = 0
Else
Pwmdunkel0 = Speedmodus10_
Pwmhell0 = Speedmodus10
Pwmdunkel = Speedmodus10_ ' 249µs + 1µs = 4khz
Pwmhell = Speedmodus10
Ison = 1
Isoff = 0
Merkerdimmung = 0
If Leu < 6 Then
Led = 5 - Leu
Else
Led = Leu
End If
If Leu >= 29 Then
S3 = 0
Ison = 0
Isoff = 1
Merkerdimmung = 0
Goto Anfang
End If
End If
Led = Led + 1
Call Outputgruppe
Call Dimmschleife
Merkerdimmung = 1
Merkerpwmdunkel = Pwmdunkel
Merkerpwmhell = Pwmhell
Merkerled = Led
Ison = 0
Isoff = 1
S3 = 0
Porta = 0
Portb = 0
Portc = 0
Portd = 0
Goto Anfangausdimmung
'######################################################################
'Globales Programm Umwandlung Zahl in PortA-D
Sub Outputs
'Da ab PortA7 die PortsB - D genutzt werden
If Leu < 8 And -1 < Leu Then
Porta.leu = Wert
Elseif 7 < Leu And Leu < 16 Then
Ledb = Leu - 8
Portb.ledb = Wert
Elseif 15 < Leu And Leu < 24 Then
Ledc = Leu - 16
Portc.ledc = Wert
Elseif 23 < Leu And Leu < 29 Then
Ledd = Leu - 24
Portd.ledd = Wert
End If
End Sub
'######################################################################
'Globales Programm manuelles Dimmen Modus 10
Sub Dimmen
If Pwmhell0 > 1 Then
Pwmdunkel0 = Pwmdunkel0 + 0.05
Pwmhell0 = Pwmhell0 - 0.05
Pwmdunkel = Round(pwmdunkel0)
Pwmhell = Round(pwmhell0)
If Pwmhell < 2 Then
Porta = 56
Wait 2
If Pind.5 = 1 Then
'Rücksprung zum Anfang
S3 = 0
Leu = 0
Led = 0
Ison = 0
Isoff = 1
Merkerdimmung = 0
Portb = 0
Portc = 0
Portd = 0
Timeron = 0
Loslass1:
Porta = 56
Waitms 100
Porta = 0
Waitms 100
If Pind.5 = 1 Then Goto Loslass1
Goto Anfang
End If
End If
End If
End Sub
'######################################################################
'Globales Programm Dimmschleife Modus 10 (separat wegen Geschwindigkeit)
Sub Dimmschleife
'Schleife Dimmung
Do
'Wenn Funk aus damm bleibt die gewählte Dimmstufe mit jedem aus ein kann eine stufe tiefer gedimmt werden
If Pind.5 = 1 Then Call Dimmen
If Pind.6 = 1 Then Goto Bewegungsmelder:
'Automatische Reduzierung
If Timeron1 = Winter Then Call Outputgruppe '4.000.000 = 60min je LED, 2.000.000 = 30min je LED
Incr Timeron1
Porta = Portnra
Portb = Portnrb
Portc = Portnrc
Portd = Portnrd
Waitus Pwmhell
Porta = 0
Portb = 0
Portc = 0
Portd = 0
Waitus Pwmdunkel
Loop
Bewegungsmelder:
End Sub
'######################################################################
'Globales Programm Umwandlung Zahl in PortA-D als Gruppe
Sub Outputgruppe
Led = Led - 1
Timeron1 = 1
If Led < 2 Then Led = 2
If Led > 21 Then
Portnra = 255
Portnrb = 255
Portnrc = 255
If Led = 28 Then Portnrd = 63
If Led = 27 Then Portnrd = 31
If Led = 26 Then Portnrd = 15
If Led = 25 Then Portnrd = 7
If Led = 24 Then Portnrd = 3
If Led = 23 Then Portnrd = 1
If Led = 22 Then Portnrd = 0
Goto Fertig
End If
If Led > 13 Then
Portnra = 255
Portnrb = 255
Portnrd = 0
If Led = 21 Then Portnrc = 127
If Led = 20 Then Portnrc = 63
If Led = 19 Then Portnrc = 31
If Led = 18 Then Portnrc = 15
If Led = 17 Then Portnrc = 7
If Led = 16 Then Portnrc = 3
If Led = 15 Then Portnrc = 1
If Led = 14 Then Portnrc = 0
Goto Fertig
End If
If Led > 5 Then
Portnra = 255
Portnrc = 0
Portnrd = 0
If Led = 13 Then Portnrb = 127
If Led = 12 Then Portnrb = 63
If Led = 11 Then Portnrb = 31
If Led = 10 Then Portnrb = 15
If Led = 9 Then Portnrb = 7
If Led = 8 Then Portnrb = 3
If Led = 7 Then Portnrb = 1
If Led = 6 Then Portnrb = 0
Goto Fertig
End If
Portnrb = 0
Portnrc = 0
Portnrd = 0
If Led = 5 Then Portnra = 127
If Led = 4 Then Portnra = 62
If Led = 3 Then Portnra = 60
If Led = 2 Then Portnra = 56
If Led = 1 Then Portnra = 48
If Led = 0 Then Portnra = 32
Fertig:
End Sub
|