+++ Hier werde ich nach und nach alle Programme aus meiner oder mit Quellangabe fremder Hand einfügen +++

bis dahin schaut in meinen Projekten Treppenlich, Einfahrtslicht. Codeschloss und Jalousiensteuerung nach. Dort sind die Programme verlinkt... Danke für Eure Geduld.


2018 - Projekt Hausarlarmanlage 

  $regfile = "m32def.dat"
  $crystal = 4000000
  $hwstack = 40
  $swstack = 16
  $framesize = 32
  '$sim
  'Programmversionen
  'Änderungshistorie:
  'V0.01  2018-02-25  Software Entwicklung + Test Hardware 10% Speicher
  'V0.02  2018-03-20  Software Entwicklung + Test Hardware 15% Speicher
  'V0.03  2018-03-28  Software Entwicklung + Test Hardware 19% Speicher
  'V0.04  2018-04-04  Software Entwicklung + Test Hardware 19% Speicher
  'V0.05  2018-04-07  neuer Motor Hardware 21% Speicher
  'V0.06  2018-04-22  Finales Programm vor Erstmontage
  'V0.07  2018-05-27  Programmanpassungen nach Erstmontage
  'V0.08  2018-06-04  Programmanpassungen nach Erstmontage
  'V0.09  2018-06-11  Programmanpassungen nach Erstmontage
  'V0.10  2018-06-17  erste vollfunktionstüchtige Version :o)
  '                   - Eichfaktor korrigiert
  '                   - erster Alarm am Tag nur Zeitansage
  '                   - Nachstellen der Uhrzeit ohne Neustellen und Eichfaktor ändern
  '                   - Pause für "Es ist jetzt
  '                   - schnelleres Stellen ohne Pausen für Ziffer aussprechen
  'V0.12  2018-07-04  Programmanpassungen
  '                   - bei Alarmaus tagsüber keine Kamerabewegung
  '                   - Nacht erst bei 3%
  '                   - Voice file 30 für Predator und nur nachts verwenden und 3x abspielen
  'V0.14  2018-07-09  Programmanpassungen
  '                   - Zeitstellen mit Minus
  '                   - Eichfaktor mit Einerstellen =  feiner
  'V0.15  2018-07-15  Programmanpassungen
  '                   - Eichfaktor mit mod besser teilen
  'V0.16  2018-07-19  Programmanpassungen
  '                   - Kameramotor sofort stoppen
  '                   - 3 mal Predator in der Nacht :o)
  'V0.17  2018-10-30  Programmanpassungen
  '                   - Kamera in mitte stellen  und nach rechts beginnen
  '                   - Kamera feiner takten, da zu schnell
  '                   - LED Kamera zeigt nun besser Tag/Nacht an
  '                   - LED Kamera zeigt nun besser Alarmaus an
  '                   - Eichfaktor entfernt da nun genau durch Quarz
  '                   - Warnleuchte blinkt nun sauber weil altes 1s Relikt gelöscht
  '                   - Hauptprogramm und Initprogramm in Unterprogramme aufgeteit
  '                   - Lautstärkeeistellung umgebaut (negiert)
  'V0.18  2018-11-03  Programmanpassungen
  '                   - Umbau Motor von 12V auf 5V Speisung
  'V0.19  2018-11-07  Programmanpassungen
  '                   - Kamera schwenkt links und rechts in mehreren Zyklen
  '                   - diverse Programmverbesserungen zum Schutz vor übelaufenden Variablen
  'V0.20  2018-12-01  Programmanpassungen
  '                   - Kamera schwenkt links und rechts in Schritten
  '                   - mehr Power auf Motor, da er im Winter schwerer geht
  'V0.21  2018-12-03  Programmanpassungen
  '                   - Kamera schwenkt in kurzen Schritten
  'V0.22  2018-12-17  Programmanpassungen
  '                   - Kamera schwenkt bei zum Weg in langsameren Schritten
  'V0.23  2019-01-03  Programmanpassungen - Version verworfen
  'V0.24  2019-07-23  Programmanpassungen
  '                   - Kamera schwenkt mit weniger Power in mehr Schritten
  '                   - Uhrzeitstellen über 0 zurück und Wochentag zurück
  '                   - Abbruch Erklärung Urzeitstellen bei Taste A/B oder nach 30 s
  '                   - Nachtschwelle verringert damit später Nacht
  '                   - Rückführung Kamera mit weniger Strom
  '                   - Nachts nur 2x Predator
  '                   - Zeitzähler nach einem Alarm erst nach Rückstellung Kamera auf 0 setzen

'************** Alle Ports als Eingang oder Ausgang definieren ****************
  '0 = Eingang; 1 = Ausgang
  Ddra = &B11111100
  Ddrb = &B01001001
  Ddrc = &B11111111
  Ddrd = &B11001111

'******* Alle Ports auf 0 bzw. 1 setzen für definierten Anfangszustände *******
  'Bei Eingängen durch 1 den Pullupnwiderstand aktivieren
  Porta = &B00000000
  Portb = &B00111111
  Portc = &B11111111
  Portd = &B01110111

'************************ analoge Eingänge einstellen *************************
  Config Adc = Single , Prescaler = Auto , Reference = Aref 'Internal
  Start Adc

'********************** 16 Bit Timer1 konfigurieren ****************************
  Config Timer1 = Timer , Prescale = 256                    'Timer konfigurieren  4000000 / 256 = 15625Hz
  Enable Timer1                                             'bei 16 bit 65535 Überlauf Startwert bei 49910
  On Timer1 Sekundeisr                                      'Timerüberlaufsprungmarke setzen
  Enable Interrupts
  Start Timer1

'************************* PWM Timer konfigurieren *****************************

  Config Timer0 = Pwm , Compare Pwm = Clear Up , Prescale = 8
  Enable Timer0
  Timer0 = 0
  Start Timer0
  Ocr0 = 0

  Config Timer2 = Pwm , Compare Pwm = Clear Down , Prescale = 1
  Enable Timer2
  Timer2 = 0
  Start Timer2
  Ocr2 = 0


'******************** Ü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

'****************************** Übersicht IO **********************************
  'IN/OUT     Pin       Typ     highactiv   Signalname
  'PA0        40        I       analog      Dämmerungsschalter
  'PA1        39        I       1           Voices active
  'PA2        38        O       1           Verstärker EIN
  'PA3        37        O       1           Volume 1 1,1k
  'PA4        36        O       1           Volume 2 10k
  'PA5        35        O       1           Volume 3 27k
  'PA6        34        O       1           Motor Polwendung
  'PA7        33        O       1           MotorEIN/AUS
  'PB0        1         O       0           Blitzlicht Warnleuchte
  'PB1        2         I       0           Configtaster Kanal D
  'PB2        3         I       0           Alarmkontakt 3 Kanal C
  'PB3        4         O       analog      PWM Warnleuchte analog
  'PB4        5         I       0           Alarmkontakt 1 Kanlal A
  'PB5        6         I       0           MOSI / Kontakte Gehäuse
  'PB6        7         O       1           MISO / Dämmerungsch LED
  'PB7        8         I       0           SKC / frei
  'PC0        22        O       0           Attiny 861A PB4 SW1
  'PC1        23        O       0           Attiny 861A PB5 SW2
  'PC2        24        O       0           Attiny 861A PB6 SW3
  'PC3        25        O       0           Attiny 861A PA3 SW4
  'PC4        26        O       0           Attiny 861A PA4 SW5
  'PC5        27        O       0           Attiny 861A PA5 SW6
  'PC6        28        O       0           Attiny 861A PA6 SW7
  'PC7        29        O       0           Attiny 861A PA7 SW8
  'PD0        14        O       0           Laserpointer 2
  'PD1        15        O       0           Laserpointer 3
  'PD2        16        O       0           LED Kamera
  'PD3        17        O       1           Elektroschock
  'PD4        18        I       0           Bewegungsmelder
  'PD5        19        I       0           Alarmkontakt 1 Kanal B
  'PD6        20        O       0           Laserpointer 1
  'PD7        21        O       analog      PWM Motor

'****************************** Subs declarieren ******************************
  Declare Sub Init
  Declare Sub Main
  Declare Sub Motorschwenken
  Declare Sub Helligkeit
  Declare Sub Voice
  Declare Sub Zeitansage
  Declare Sub Uhrzeitstellen
  Declare Sub Alarmausein
  Declare Sub Systemcheck
'********************** globale Variablen declarieren *************************
  'Zeitmerker
  Dim Eichfaktor As Word
  Dim Sekunde As Byte
  Dim Minute As Byte
  Dim Stunde As Byte
  Dim Wochentag As Byte
  Dim Zeit1 As Byte                                         'Zeitmerker1
  Dim Zeit2 As Byte                                         'Zeitmerker2
  Dim Zeit3 As Byte                                         'Zeitmerker3
  Dim Zeit4 As Byte                                         'Zeitmerker5
  Dim Zeit5 As Word                                         'Zeitmerker6

  'Voicemerker
  Dim File As Byte                                          'Merker Datei Voices
  'Helligkeiten
  Dim Werthell As Long                                      'Helligkeit Tag/Nacht
  Dim Tag As Bit
  'Zähler
  Dim I As Word
  Dim J As Word
  Dim K As Word
  Dim L As Word
  Dim M As Word
  Dim A As Word
  Dim B As Word

  'Merker
  Dim Alarmbew As Byte
  Dim Alarmfunk1 As Bit
  Dim Alarmfunk2 As Bit
  Dim Alarmfunk3 As Bit
  Dim Alarmgeh As Bit
  Dim Motor As Bit
  Dim Warnleuchte As Byte
  Dim Check As Bit
  Dim Pwmwarnl As Byte
  Dim Pwmmotor As Byte
  Dim Alarmein As Byte
  Dim Alarmeinx As Eram Byte
  Dim Volume As Byte
  Dim Stellen As Bit
  Dim Alarmzeit As Word

  'Variablen Plausibel Setzen
  Eichfaktor = 49910
  Portc = 255

  Wochentag = 4
  Stunde = 12
  Minute = 42
  Sekunde = 0

  Stellen = 0
  Zeit1 = 0
  Zeit2 = 0
  Zeit3 = 0
  Zeit4 = 0
  Zeit5 = 0
  File = 1
  Werthell = 0
  Tag = 1
  I = 0
  J = 0
  K = 0
  L = 0
  M = 0
  A = 0
  B = 0
  Alarmbew = 0
  Alarmfunk1 = 0
  Alarmfunk2 = 0
  Alarmfunk3 = 0
  Alarmgeh = 0
  Motor = 0
  Warnleuchte = 0
  Check = 0
  Pwmwarnl = 0
  Ocr0 = 0
  Ocr2 = 0
  Alarmein = Alarmeinx
  Volume = 1
  Alarmzeit = 333                                           'Faktor 180ms 333x0,180 = 60s
  Call Init

'==============================================================================
'==============================================================================
'==============================================================================
'*************************** Startprogramm Init *******************************
  Sub Init
  Porta.= 0
  Wait 1
  Porta.= 1
  Zeit3 = 0
  Wait 1
  If Pinb.= 1 Then
    File = 1                                                'Systemstart
    Call Voice
    'Softwareversion  0,24
    File = 148
    Call Voice
    File = 152
    Call Voice
    File = 154
    Call Voice
    Call Main
  Else
    File = 16
    Call Voice
    Call Systemcheck
  End If
  End Sub

'==============================================================================
'==============================================================================
'==============================================================================
'****************************** Hauptprogramm *********************************
  Sub Main
  Zeit1 = 0
  Zeit4 = 0
  Zeit5 = 0
  Alarmbew = 0
  Volume = 1

'******************************************************************************
  Hauptschleife:
  Check = 0

  'Abfrage Helligkeiten
  Call Helligkeit

  'Verstärker nach 15s ausschalten
  If Zeit3 > 15 Then
    Porta.= 0
  End If

  'Einausschalten Alarmanlage über Taste D
  If Pinb.= 0 Then Call Alarmausein

  '30s warten bis Bewegungsmelder den selbstcheck durchgeführt hat oder wenn Spannungsausfall
  If Zeit1 < 30 Then Goto Alarmanlageaus

  'Abfrage Alarmkontakte
  'If Alarmein = 1 And Pinb.4 = 0 Then Alarmfunk1 = 1 Else Alarmfunk1 = 0
  If Alarmein = 1 And Pind.= 0 Then Alarmfunk2 = 1 Else Alarmfunk2 = 0
  If Alarmein = 1 And Pinb.= 0 Then Alarmfunk3 = 1 Else Alarmfunk3 = 0
  If Pinb.= 0 Then Alarmgeh = 1 Else Alarmgeh = 0


  'Bewegungsmelder
  If Pind.= 0 Then Alarmbew = Alarmbew + 1
  'If Pinb.4 = 0 Then Alarmbew = Alarmbew + 1   'nur Test ohne Bewegungsmelder, dann Kanal A = Bewegungsmelder
  If Alarmbew > 4 Then Alarmbew = 5

  'nach 1min Alarmzähler zurücksetzen und über vier erst nach 30min
  If Zeit4 = 60 And Alarmbew < 5 Then Alarmbew = 0
  If Zeit5 > 1800 And Alarmbew > 4 Then
     Alarmbew = 0
     Zeit5 = 0
  End If

  'Alarm steuern
  If Pind.= 0 Or Alarmfunk1 = 1 Or Alarmfunk2 = 1 Or Alarmfunk3 = 1 Or Alarmgeh = 1 Then
     'If Pinb.4 = 0 Then                          'nur Test ohne Bewegungsmelder, dann Kanal A = Bewegungsmelder
       '1.Voralarm nachts mit Predator
       If Alarmbew = 1 And Pind.= 0 Then
         If Tag = 1 Then
           Volume = 1
           Call Zeitansage
         Else
           Volume = 1
           File = 30
           Call Voice
         End If
       End If
       If Alarmbew = 2 And Pind.= 0 Then
         If Tag = 1 Then File = Rnd(3) + 31 Else File = Rnd(4) + 35
         If Tag = 1 Then Volume = 2 Else Volume = 1
         If Pinb.= 0 Then Goto Alarmsofortaus
         Call Voice
       End If

       If Alarmgeh = 1 Then
         If Tag = 1 Then File = Rnd(4) + 100 Else File = Rnd(4) + 105
         If Tag = 1 Then Volume = 4 Else Volume = 1
         If Pinb.= 0 Then Goto Alarmsofortaus
         Call Voice
       End If

       If Alarmein = 0 Then Goto Ohnearlarme

       If Alarmbew = 3 And Pind.= 0 Then
         If Tag = 1 Then File = Rnd(4) + 40 Else File = Rnd(4) + 45
         If Tag = 1 Then Volume = 3 Else Volume = 1
         If Pinb.= 0 Then Goto Alarmsofortaus
         Call Voice
       End If
       If Alarmbew = 4 And Pind.= 0 Then
         If Tag = 1 Then File = Rnd(4) + 50 Else File = Rnd(4) + 55
         If Tag = 1 Then Volume = 4 Else Volume = 1
         Call Voice
       End If
       If Alarmfunk1 = 1 Then
         If Tag = 1 Then File = Rnd(4) + 60 Else File = Rnd(4) + 65
         If Tag = 1 Then Volume = 5 Else Volume = 1
         If Pinb.= 0 Then Goto Alarmsofortaus
         Call Voice
       End If
       If Alarmfunk2 = 1 Then
         If Tag = 1 Then File = Rnd(4) + 70 Else File = Rnd(4) + 75
         If Tag = 1 Then Volume = 5 Else Volume = 1
         If Pinb.= 0 Then Goto Alarmsofortaus
         Call Voice
       End If
       If Alarmfunk3 = 1 Then
         If Tag = 1 Then File = Rnd(4) + 80 Else File = Rnd(4) + 85
         If Tag = 1 Then Volume = 5 Else Volume = 1
         If Pinb.= 0 Then Goto Alarmsofortaus
         Call Voice
       End If

       Ohnearlarme:

       'Warnleuchte
       If Alarmbew = 1 Then Pwmwarnl = 2
       If Alarmbew = 2 Then Pwmwarnl = 3
       If Alarmbew = 3 Then Pwmwarnl = 80
       If Alarmbew = 4 Or Alarmfunk1 = 1 Or Alarmfunk2 = 1 Or Alarmfunk3 = 1 Or Alarmgeh = 1 Then
         Pwmwarnl = 255
         Ocr0 = Pwmwarnl
       End If

       Ocr0 = Pwmwarnl

       'Elektroschock und LED Kamera
       Portd.= 1                                          'Bei Alarm blinkt nachts die Kammera LED nicht
       I = 0
       J = 0
       K = 0
       M = 10
       A = 0
       K = 0
       Pwmmotor = 140
       Ocr2 = Pwmmotor
       For I = 1 To Alarmzeit

            'Taste D für Abbruch Alarm abfragen
            If Pinb.= 0 Then Goto Alarmsofortaus
            'Sirene wenn kein Voralarm oder anderer Alarm, nur 3x und wenn vorangehende Sirene fertig
            If Alarmfunk1 = 1 Or Alarmfunk2 = 1 Or Alarmfunk3 = 1 Or Alarmgeh = 1 Then
              'Zweiter Zähler und 6x Alarm wenn vorheriger zuende ist
              If J < 5 And Pina.= 0 Then
                If J < 5 Then J = J + 1 Else J = 6
                File = Rnd(4) + 92
                If Tag = 1 Then Volume = 5 Else Volume = 3
                If Alarmein = 1 Then Call Voice
              End If
            End If

            If Alarmbew = 1 And Tag = 0 Then
              If I = 150 Then                               ' Nachts ein zweites Mal den Predator
                Zeit3 = 0
                Porta.= 0
                Porta.= 0
                Porta.= 0
                File = 255 - 30
                Portc = File
              End If
            End If

            If Alarmbew > 0 Then Portb.= 0                'Warnleuchte AUS
            If I > 50 And Alarmgeh = 1 And Alarmein = 1 Then Portd.= 1       'Elektroschock
            Call Motorschwenken                             'Motor ansteuern
            Waitms 7
            Portd.= 0                                     'Warnleuchte aus
            'Porta.7 = 0                                           'Ende Motorzyklus
            Waitms 53
            Portb.= 1                                     'Warnleuchte blitzt

            If Tag = 1 And A = 5 Then Portd.= 0           'LED Camera
            If Portd.= 1 Then Portd.= 0 Else Portd.= 1       'Laserpointer 1 EIN/AUS
            If Portd.= 1 Then Portd.= 0 Else Portd.= 1       'Laserpointer 2 EIN/AUS
            If Portd.= 1 Then Portd.= 0 Else Portd.= 1       'Laserpointer 3 EIN/AUS

            Waitms 60


            If Portd.= 1 Then Portd.= 0 Else Portd.= 1       'Laserpointer 1 EIN/AUS
            If Portd.= 1 Then Portd.= 0 Else Portd.= 1       'Laserpointer 2 EIN/AUS
            If Portd.= 1 Then Portd.= 0 Else Portd.= 1       'Laserpointer 3 EIN/AUS

            Waitms 60

            If Portd.= 1 Then Portd.= 0 Else Portd.= 1       'Laserpointer 1 EIN/AUS
            If Portd.= 1 Then Portd.= 0 Else Portd.= 1       'Laserpointer 2 EIN/AUS
            If Portd.= 1 Then Portd.= 0 Else Portd.= 1       'Laserpointer 3 EIN/AUS
            Portd.= 1
            If A > 4 Then A = 0
            A = A + 1
            Portc = 255

       Next I

       Porta.= 0                                          'Motor sofort aus
       Portd.= 1                                          'Laserpointer 1 AUS
       Portd.= 1                                          'Laserpointer 2 AUS
       Portd.= 1                                          'Laserpointer 3 AUS

       'Warten bis alle Sensoren wieder aus
       I = 0

       Warteendealarm:
       'Verstärker nach 15s ausschalten
       If Zeit3 > 15 Then
         Porta.= 0
       End If

       'Kamera LED blinkt dauerhaft
       Portd.= 0
       Waitms 100
       Portd.= 1

       If I < 122 Then
         I = I + 1
         If Pind.= 1 And Pinb.= 1 And Pind.= 1 And Pinb.= 1 And Pinb.= 1 Then
           Wait 1
           If Pind.= 0 Or Pinb.= 0 Or Pind.= 0 Or Pinb.= 0 Or Pinb.= 0 Then
             File = 97
             If I = 120 And Alarmein = 1 Then Call Voice
             Goto Warteendealarm
           End If
         End If
       Else
         Goto Warteendealarm
       End If

       'Merker zurücksetzen
       I = 0
       J = 0
       K = 0
       M = 0
       A = 0

       'Kamera in Mitte bringen
       Porta.= 0
       Porta.= 1
       Pwmmotor = 150
       Ocr2 = Pwmmotor
       Waitms 2500
       Porta.= 0
       Waitms 100
       Porta.= 1
       Waitms 100
       Porta.= 1
       Waitms 1000
       Ocr2 = 0
       Porta.= 0
       Porta.= 0

       'Zeiten reseten
       Zeit1 = 0
       Zeit4 = 0
       Zeit5 = 0
  End If

    Alarmanlageaus:
    Alarmgeh = 0
    Alarmfunk1 = 0
    Alarmfunk2 = 0
    Alarmfunk3 = 0
    Portd.= 1                                             'Laserpointer 1 AUS
    Portd.= 1                                             'Laserpointer 2 AUS
    Portd.= 1                                             'Laserpointer 3 AUS
    Volume = 1
    Porta.= 0
    Porta.= 0
    Ocr0 = 0
    Ocr2 = 0
    Porta.= 0

    'LED Kamera
    If Zeit1 < 30 Then
     'wenn Alarmanlage durch Alarm noch 30 s wartet, dann dauerhaft LED Kamera EIN
      Portd.= 0
    Else
      If Alarmein = 1 Then
        If A = 1 Or A = 3 Then Portd.= 0                  'mit scharfem Alarm 2x 0,05s Pause 0,15s
      Else
        If A = 1 Or A = 3 Or A = 6 Then Portd.= 0         'mit deakt.Alarm 3x 0,05s Pause 0,15s und 1s aus
      End If
      A = A + 1
      If Tag = 1 Then
        If A > 23 Then A = 0                                '1s aus
      Else
        If A > 46 Then A = 0                                '2s aus
      End If
    End If

  Waitms 20

  If Zeit1 > 30 Then Portd.= 1

  Waitms 30

  Goto Hauptschleife

  End Sub

'******************************************************************************
'==============================================================================
'==============================================================================
'==============================================================================
'********************** Unterprogramm Motor schwenken *************************
  Sub Motorschwenken
  K = K + 1
     If K = 1 Then Porta.= 0                              '1x 180ms = 180ms Motor
     If K = 3 Then
         If Porta.= 0 Then M = M + 1                      '2x 180ms = 0,32s Pause
         If Porta.= 1 Then M = M - 1
         If M = 25 Then Porta.= 1                         'nach 25  Pausen Polwendung
         If M = 0 Then Porta.= 0
         If Porta.= 0 Then Ocr2 = 110 Else Ocr2 = 110
         Porta.= 1
         K = 0
     End If
  End Sub
'==============================================================================
'==============================================================================
'==============================================================================
'************************* Unterprogramm Tag-Nacht ****************************
  Sub Helligkeit
  'checke alle Ein und Ausgaben
  'Tag oder Nacht abfragen
  Werthell = Getadc(0)
  Werthell = Werthell - 1024                                'Wert negieren, da 5V = Nacht = 0%
  Werthell = Werthell / -10                                 'Wert durch -10 damit Wert positiv und von 0-102
  If Werthell > 4 And Tag = 0 Then                          'Dämmerungsschalter
    'Tag
    Tag = 1
    Portb.= 1
    File = 2
    Volume = 1
    Call Voice                                              'Dämmerungsch LED
    Elseif Werthell < 1 And Tag = 1 Then
     'Nacht
      Tag = 0
      Portb.= 0
      File = 3
      Volume = 1
      Call Voice                                            'Dämmerungsch LED
  End If
  End Sub
'==============================================================================
'==============================================================================
'==============================================================================
'*********************** Unterprogramm Uhrzeit Stellen *************************
  Sub Uhrzeitstellen
  File = 147                                                'Uhrzeitstellen
  Call Voice
  Warteauftasteab:
  Waitms 100
  If Pinb.= 0 Or Pinb.= 0 Or Zeit3 > 30 Then Stellen = 1 Else Goto Warteauftasteab
  'Wochentag
  For I = 1 To 20
    File = Wochentag + 210                                  'Mo-So
    Call Voice
    Wartewotagesagt:
    Waitms 200
    'wenn noch eine Ansage läuft warten
    If Pinb.= 0 Or Zeit3 > 60 Then Goto Wochentagfertig
    If Pinb.= 1 And Pind.= 1 Then Goto Wartewotagesagt
    If Pinb.= 0 Then Wochentag = Wochentag + 1
    If Pind.= 0 Then Wochentag = Wochentag - 1
    If Wochentag > 7 Then Wochentag = 1
    If Wochentag < 1 Then Wochentag = 7
  Next I
  Wochentagfertig:
  Wait 1
  For I = 1 To 50
    File = Stunde + 220                                     'Stunde + Uhr
    Call Voice
    Wartestundegesagt:
    Waitms 200
    'wenn noch eine Ansage läuft warten
    If Pinb.= 0 Or Zeit3 > 15 Then Goto Stundefertig
    If Pinb.= 1 And Pind.= 1 Then Goto Wartestundegesagt
    If Pinb.= 0 Then
      Stunde = Stunde + 1
      If Stunde > 23 Then Stunde = 0
    End If
    If Pind.= 0 Then
      If Stunde = 0 Then Stunde = 24
      Stunde = Stunde - 1
    End If
  Next I
  Stundefertig:
  Wait 1
  For I = 1 To 121
    File = Minute + 150
    If File = 150 Then File = 149
    Call Voice
    Warteminutegesagt:
    Waitms 200
    'wenn noch eine Ansage läuft warten
    If Pinb.= 0 Or Zeit3 > 15 Then Goto Minutefertig
    If Pinb.= 1 And Pind.= 1 Then Goto Warteminutegesagt
    If Pinb.= 0 Then
      Minute = Minute + 1
      If Minute > 59 Then Minute = 0
      Sekunde = 0
    End If
    If Pind.= 0 Then
      If Minute = 0 Then Minute = 60
      Minute = Minute - 1
      Sekunde = 0
    End If
  Next I
  Minutefertig:
  File = 148                                                'Uhrzeitstellen fertig
  Call Voice
  Stellen = 0
  Call Zeitansage
  End Sub
 '==============================================================================
'==============================================================================
'==============================================================================
'*********************** Unterprogramm Zeitansage *****************************
  Sub Zeitansage
  File = 145                                                'es ist jetzt
  Call Voice
  File = Wochentag + 210                                    'Mo-So
  Call Voice
  File = Stunde + 220                                       'Stunde + Uhr
  Call Voice
  File = Minute + 150                                       'Minute
  If Minute > 0 Then Call Voice
  Stellen = 0
  Eichfaktor = 49910
  End Sub
'===============================================================================
'===============================================================================
'===============================================================================
'*********************** Unterprogramm Alarmausein *****************************
  Sub Alarmausein

  Portd.= 1                                               'Laserpointer 1 AUS
  Portd.= 1                                               'Laserpointer 2 AUS
  Portd.= 1                                               'Laserpointer 3 AUS
  If Alarmein = 0 Then
    Alarmein = 1
    Alarmeinx = 1
    File = 91
    Volume = 2
    Call Voice
  Else
    Alarmsofortaus:
    Alarmein = 0
    Alarmeinx = 0
    File = 90
    Volume = 2
    Call Voice
  End If
  Alarmbew = 0
  Alarmgeh = 0
  Alarmfunk1 = 0
  Alarmfunk2 = 0
  Alarmfunk3 = 0
  Loslassalarmaus:
  Waitms 100
  If Pinb.= 0 Then Goto Loslassalarmaus

  'Uhrzeit einstellen wenn Taste D nochmal gedrückt wird
  For I = 1 To 30
    If Pinb.= 0 Then
      Loslassalstellen:
      Waitms 100
      If Pinb.= 0 Then Goto Loslassalstellen
      Call Uhrzeitstellen
    End If
    Waitms 100
  Next I
  End Sub

'===============================================================================
'===============================================================================
'===============================================================================
'*********************** Unterprogramm Systemcheck *****************************
Sub Systemcheck
  Zeit1 = 0
  Check = 1
  File = 1
  Volume = 1
  Call Voice
  Call Zeitansage
  Call Helligkeit
  Calibrierung:
  If Tag = 1 Then                                           'Dämmerungsschalter
    File = 2
    Portb.= 0                                             'Dämmerungsch LED
  Else
    File = 3
    Portb.= 1                                             'Dämmerungsch LED
  End If
  Call Voice
  Voicefertig:
  Waitms 100
  'Einstellung Dämmerungsschalter, wenn fertig Taste D drücken
  If Pinb.= 0 Then Goto Volumetest
  'wenn noch eine Ansage läuft warten
  If Pina.= 1 Then Goto Voicefertig1
  Goto Calibrierung

  Volumetest:
  Waitms 100
  If Pinb.= 0 Or Pina.= 1 Or Pina.= 0 Then Goto Volumetest:

  Volume1:
  Volume = 1
  File = 110
  Call Voice
  Voicefertig1:
  Waitms 100
  'Einstellung Lautstärkestufe 1 - mit D Lautstärke komplett überspringen
  If Pinb.= 0 Then Goto Volumefertig
  'Wenn Volume1 fertig Taste A drücken
  If Pinb.= 0 Then Goto Volume2
  'wenn noch eine Ansage läuft warten
  If Pina.= 1 Then Goto Voicefertig1
  Goto Volume1

  Volume2:
  Volume = 2
  File = 111
  Call Voice
  Voicefertig2:
  Waitms 100
  'Einstellung Lautstärkestufe 2 - mit D Lautstärke komplett überspringen
  If Pinb.= 0 Then Goto Volumefertig
  'Mit Taste B zurück zu Volume1
  If Pind.= 0 Then Goto Volume1
  'Wenn Volume2 fertig Taste A drücken
  If Pinb.= 0 Then Goto Volume3
  'wenn noch eine Ansage läuft warten
  If Pina.= 1 Then Goto Voicefertig2
  Goto Volume2

  Volume3:
  Volume = 3
  File = 112
  Call Voice
  Voicefertig3:
  Waitms 100
  'Einstellung Lautstärkestufe 3 - mit D Lautstärke komplett überspringen
  If Pinb.= 0 Then Goto Volumefertig
  'Mit Taste B zurück zu Volume2
  If Pind.= 0 Then Goto Volume2
  'Wenn Volume2 fertig Taste A drücken
  If Pinb.= 0 Then Goto Volume4
  'wenn noch eine Ansage läuft warten
  If Pina.= 1 Then Goto Voicefertig3
  Goto Volume3

  Volume4:
  Volume = 4
  File = 113
  Call Voice
  Voicefertig4:
  Waitms 100
  'Einstellung Lautstärkestufe 4 - mit D Lautstärke komplett überspringen
  If Pinb.= 0 Then Goto Volumefertig
  'Mit Taste B zurück zu Volume3
  If Pind.= 0 Then Goto Volume3
  'Wenn Volume4 fertig Taste A drücken
  If Pinb.= 0 Then Goto Volume5
  'wenn noch eine Ansage läuft warten
  If Pina.= 1 Then Goto Voicefertig4
  Goto Volume4

  Volume5:
  Volume = 5
  File = 114
  Call Voice
  Voicefertig5:
  Waitms 100
  'Einstellung Lautstärkestufe 5 - mit D Lautstärke komplett überspringen
  If Pinb.= 0 Then Goto Volumefertig
  'Mit Taste B zurück zu Volume4
  If Pind.= 0 Then Goto Volume4
  'Wenn Volume5 fertig Taste A drücken
  If Pinb.= 0 Then Goto Volumefertig
  'wenn noch eine Ansage läuft warten
  If Pina.= 1 Then Goto Voicefertig5
  Goto Volume5

  Volumefertig:
  Volume = 1

  Loslassd2:
  Waitms 100
  If Pinb.= 0 Or Pinb.= 0 Then Goto Loslassd2


  Volume = 1
  If Pind.= 0 Then File = 7 Else File = 8                 'Bewegungsmelder
  If Pinb.= 0 Then Goto Loslassd3
  Call Voice
  If Pinb.= 0 Then File = 9 Else File = 10                'Alarmkontakt 1
  If Pinb.= 0 Then Goto Loslassd3
  Call Voice
  If Pind.= 0 Then File = 11 Else File = 12               'Alarmkontakt 2
  If Pinb.= 0 Then Goto Loslassd3
  Call Voice
  If Pind.= 0 Then File = 13 Else File = 14               'Alarmkontakt 3
  If Pinb.= 0 Then Goto Loslassd3
  Call Voice
  If Pinb.= 0 Then File = 17 Else File = 18               'Kontakte Gehäuse
  If Pinb.= 0 Then Goto Loslassd3
  Call Voice

  Loslassd3:
  Waitms 100
  If Pinb.= 0 Or Pina.= 1 Then Goto Loslassd3


  File = 19
  Call Voice

  Lasertest:
  Portd.= 0                                               'Laserpointer 1
  Portd.= 1
  Waitms 50
  Portd.= 0                                               'Laserpointer 2
  Portd.= 1
  Waitms 50
  Portd.= 0                                               'Laserpointer 3
  Portd.= 1
  Waitms 50
  If Pinb.= 1 Then Goto Lasertest

  'Wenn Lasercalibrierung fertig Taste D drücken
  Loslassd4:
  Waitms 100
  If Pinb.= 0 Or Pina.= 1 Then Goto Loslassd4
  Portd.= 1
  Portd.= 1
  Portd.= 1

  File = 20
  Call Voice

  Wait 1

  File = 21
  Call Voice
  Ledkameratest:
  Portd.= 0                                               'LED Kamera
  Waitms 100
  Portd.= 1
  Waitms 100
  If Pinb.= 1 Then Goto Ledkameratest
  'Wenn Ledkameratest fertig Taste D drücken
  Loslassd5:
  Waitms 100
  If Pinb.= 0 Or Pina.= 1 Then Goto Loslassd5
  File = 22
  Call Voice

  Wait 1

  File = 23
  If Pinb.= 1 Then Call Voice
  For I = 1 To 10
    Portd.= 1                                             'Elektroschock
    Waitms 5
    Portd.= 0
    Waitms 1000
  Next I
  File = 24
  Call Voice

  Wait 1

  File = 25
  Call Voice
  For I = 0 To 10
    Pwmwarnl = I
    Ocr0 = Pwmwarnl
    Waitms 500
    Portb.= 0                                             'Blitzlicht Warnleuchte
    Waitms 100
    Portb.= 0
  Next I
  Portb.= 1
  Pwmwarnl = 0
  Ocr0 = Pwmwarnl
  File = 26
  Call Voice

  Wait 1


  File = 27
  Call Voice
  Ocr2 = 190
  For I = 1 To 70
    Porta.= 1                                             'Motor
    If I > 20 And I < 50 Then Porta.= 1
    If I = 21 Then
      File = 28
      Call Voice                                            'Motor Polwendung
    End If
    If I > 50 Then Porta.= 0                              'Motor Polwendung
    Waitms 300
  Next I
  Porta.= 0
  Porta.= 0
  Ocr2 = 0
  File = 29
  Call Voice

  Wait 1

  File = 15
  Call Voice
  Check = 0
  Call Main
  End Sub

'==============================================================================
'==============================================================================
'==============================================================================
'*************************** Unterprogramm Voice ******************************
  'Programm 8 bit decoder für sound
  'PC0        1         O        Attiny 861A PB4 SW1
  'PC1        2         O        Attiny 861A PB5 SW2
  'PC2        3         O        Attiny 861A PB6 SW3
  'PC3        4         O        Attiny 861A PA3 SW4
  'PC4        5         O        Attiny 861A PA4 SW5
  'PC5        3         O        Attiny 861A PA5 SW6
  'PC6        4         O        Attiny 861A PA6 SW7
  'PC7        5         O        Attiny 861A PA7 SW8

  Sub Voice

  Zeit3 = 0
  Wartebistonaus:
  'wenn noch eine Ansage läuft warten
  If Pina.= 1 And Stellen = 0 Then Goto Wartebistonaus

  'Vertärker ein
  Portc = 255
  If Porta.= 0 Then
    Porta.= 0
    Porta.= 0
    Porta.= 0
    Waitms 100
    Porta.= 1
    Wait 1
  End If

  'Lautstärke einstellen
  If Volume = 1 Or Volume = 0 Or Volume > 5 Then            '200k
    '50k, 50k, 100k
    Porta.= 0
    Porta.= 0
    Porta.= 0
    Elseif Volume = 2 Then                                  '-50k
      Porta.= 1
      Porta.= 0
      Porta.= 0
      Elseif Volume = 3 Then                                '-100k
        Porta.= 1
        Porta.= 1
        Porta.= 0
        Elseif Volume = 4 Then                              '-150k
          Porta.= 0
          Porta.= 1
          Porta.= 1
          Elseif Volume = 5 Then                            '-200k = 0k
            Porta.= 1
            Porta.= 1
            Porta.= 1

  End If


  'wenn Voice Stopp oder Gruppe ankommt, wird das Warten auf noch laufende Voices abgebrochen
  If File > 0 And File < 255 Then Goto Weiter

  Weiter:
  'da das 8bit Muster negativ sein muss (0= aktiv) muss 255- file gerechenet werden
  'Bsp. file 1 = 255 =   11111110
  If File < 255 Then File = 255 - File Else File = 255      'Bei Überlauf Stop ausgeben
  Portc = File
  Waitms 100
  Portc = 255
  L = 0
  Warteaufton:
  L = L + 1
  Waitms 10
  'warten bis Ansage kommt und wenn nicht nach 2s abbrechen
  If Pina.= 0 And L < 200 And Stellen = 0 Then Goto Warteaufton
  File = 0
  Volume = 1
  End Sub


'==============================================================================
'==============================================================================
'==============================================================================
'*************************** Unterprogramm Sekundentimer ******************************
 'Uhrzeitinterupt
  Sekundeisr:
  Timer1 = Eichfaktor                                       '= Startwert für eine s je Überlauf
  Incr Sekunde
  Incr Zeit1                                                'Timer Zähler Bewegungsalarm unterdrücken
  Incr Zeit2                                                'Timer für Systemcheckmaximalzeit
  Incr Zeit3                                                'Timer Verstärkerzeit
  Incr Zeit4                                                'Timer Zähler Bewegungsalarm zurücksetzen
  Incr Zeit5                                                'Timer Zähler 4,Bewegungsalarm zurücksetzen

  'Überlauf Zeitvariablen begrenzen
  If Sekunde > 254 Then Sekunde = 254
  If Zeit1 > 254 Then Zeit1 = 254
  If Zeit2 > 254 Then Zeit2 = 254
  If Zeit3 > 254 Then Zeit3 = 254
  If Zeit4 > 254 Then Zeit4 = 254
  If Zeit5 > 3600 Then Zeit5 = 3600

  'Wenn Systemcheckzeit über 4min dann abbruch
  If Check = 1 And Zeit2 = 240 Then
    Check = 0
    File = 15
    Call Voice
    Call Main
  End If

    If Sekunde > 59 Then
      Sekunde = 0
      Minute = Minute + 1
    End If
    If Minute > 59 Then
      Minute = 0
      Stunde = Stunde + 1
    End If
    If Stunde > 23 Then
      Stunde = 0
      Sekunde = 0
      If Wochentag > 6 Or Wochentag = 0 Then Wochentag = 1 Else Wochentag = Wochentag + 1
    End If
    If Sekunde = 0 And Minute = 0 Then
      If Tag = 1 Then
        Volume = 2
      Else
        Volume = 1
      End If
      If Alarmein = 1 Then Call Zeitansage
    End If


  Return
  End

   'Übersicht Voicedateien
   'File 1    =   Systemstart
   'File 2    =   Dämmerungsschalter Tagmeldung
   'File 3    =   Dämmerungsschalter Nachtmeldung
   'File 4-6  =   3x frei
   'File 110  =   Volume Stufe 1
   'File 111  =   Volume Stufe 2
   'File 112  =   Volume Stufe 3
   'File 113  =   Volume Stufe 4
   'File 114  =   Volume Stufe 5
   'File 115  =   Volume Stufe 6
   'File 116  =   Volume Stufe 7
   'File 7    =   Begeungsmelder EIN
   'File 8    =   Begeungsmelder AUS
   'File 9    =   Alarmkontakt Funk 1 EIN
   'File 10   =   Alarmkontakt Funk 1 AUS
   'File 11   =   Alarmkontakt Funk 2 EIN
   'File 12   =   Alarmkontakt Funk 2 AUS
   'File 13   =   Alarmkontakt Funk 3 EIN
   'File 14   =   Alarmkontakt Funk 3 AUS
   'File 15   =   Configtaster EIN
   'File 16   =   Configtaster AUS
   'File 17   =   Gehäusekontakt EIN
   'File 18   =   Gehäusekontakt AUS
   'File 19   =   Laserpointercheck Start
   'File 20   =   Laserpointercheck abgeschlossen
   'File 21   =   LED Kameracheck  Start
   'File 22   =   LED Kameracheck  abgeschlossen
   'File 23   =   Check Elektroschock Start
   'File 24   =   Check Elektroschock abgeschlossen
   'File 25   =   Warnleuchtencheck Start
   'File 26   =   Warnleuchtencheck abgeschlossen
   'File 27   =   Servomotorcheck Start
   'File 28   =   Servomotorcheck abgeschlossen
   'File 29   =   Servomotorcheck abgeschlossen
   'File 30   =   Voralarm Predator
   'File 31   =   Voralarm1 Beweg Tag
   'File 32   =   Voralarm1 Beweg Tag
   'File 33   =   Voralarm1 Beweg Tag
   'File 34   =   Voralarm1 Beweg Tag
   'File 35   =   Voralarm1 Beweg Nacht
   'File 36   =   Voralarm1 Beweg Nacht
   'File 37   =   Voralarm1 Beweg Nacht
   'File 38   =   Voralarm1 Beweg Nacht
   'File 39   =   Voralarm1 Beweg Nacht
   'File 40   =   Voralarm2 Beweg Tag
   'File 41   =   Voralarm2 Beweg Tag
   'File 42   =   Voralarm2 Beweg Tag
   'File 43   =   Voralarm2 Beweg Tag
   'File 44   =   Voralarm2 Beweg Tag
   'File 45   =   Voralarm2 Beweg Nacht
   'File 46   =   Voralarm2 Beweg Nacht
   'File 47   =   Voralarm2 Beweg Nacht
   'File 48   =   Voralarm2 Beweg Nacht
   'File 49   =   Voralarm2 Beweg Nacht
   'File 50   =   Alarm Beweg Tag
   'File 51   =   Alarm Beweg Tag
   'File 52   =   Alarm Beweg Tag
   'File 53   =   Alarm Beweg Tag
   'File 54   =   Alarm Beweg Tag
   'File 55   =   Alarm Beweg Nacht
   'File 56   =   Alarm Beweg Nacht
   'File 57   =   Alarm Beweg Nacht
   'File 58   =   Alarm Beweg Nacht
   'File 59   =   Alarm Beweg Nacht
   'File 60   =   Alarm Funk1 Tag
   'File 61   =   Alarm Funk1 Tag
   'File 62   =   Alarm Funk1 Tag
   'File 63   =   Alarm Funk1 Tag
   'File 64   =   Alarm Funk1 Tag
   'File 65   =   Alarm Funk1 Nacht
   'File 66   =   Alarm Funk1 Nacht
   'File 67   =   Alarm Funk1 Nacht
   'File 68   =   Alarm Funk1 Nacht
   'File 69   =   Alarm Funk1 Nacht
   'File 70   =   Alarm Funk2 Tag
   'File 71   =   Alarm Funk2 Tag
   'File 72   =   Alarm Funk2 Tag
   'File 73   =   Alarm Funk2 Tag
   'File 74   =   Alarm Funk2 Tag
   'File 75   =   Alarm Funk2 Nacht
   'File 76   =   Alarm Funk2 Nacht
   'File 77   =   Alarm Funk2 Nacht
   'File 78   =   Alarm Funk2 Nacht
   'File 79   =   Alarm Funk2 Nacht
   'File 80   =   Alarm Funk3 Tag
   'File 81   =   Alarm Funk3 Tag
   'File 82   =   Alarm Funk3 Tag
   'File 83   =   Alarm Funk3 Tag
   'File 84   =   Alarm Funk3 Tag
   'File 85   =   Alarm Funk3 Nacht
   'File 86   =   Alarm Funk3 Nacht
   'File 87   =   Alarm Funk3 Nacht
   'File 88   =   Alarm Funk3 Nacht
   'File 89   =   Alarm Funk3 Nacht
   'File 90   =   AlarmAUS
   'File 91   =   AlarmEIN
   'File 92   =   Alarmsignal 1
   'File 93   =   Alarmsignal 2
   'File 94   =   Alarmsignal 3
   'File 95   =   Alarmsignal 4
   'File 96   =   Alarmsignal 5
   'File 97   =   Noch ein Kontakt aktiv
   'File 98-99 =  2x frei
   'File 100  =   Alarm Gehäuse Tag
   'File 101  =   Alarm Gehäuse Tag
   'File 102  =   Alarm Gehäuse Tag
   'File 103  =   Alarm Gehäuse Tag
   'File 104  =   Alarm Gehäuse Tag
   'File 105  =   Alarm Gehäuse Nacht
   'File 106  =   Alarm Gehäuse Nacht
   'File 107  =   Alarm Gehäuse Nacht
   'File 108  =   Alarm Gehäuse Nacht
   'File 109  =   Alarm Gehäuse Nacht
   'File 117-144 = 28x frei
   'File 145  =   es ist jetzt
   'File 146  =   Eichfaktor erkannt
   'File 147  =   Stellen
   'File 148  =   Uhr erfolgreich gestellt
   'File 149  =   Null
   'File 150  =   ein für Stunde Ein Uhr ...
   'File 151-209 = 1 - 59 als Zahlen gesprochen für Stunde+Min
   'File 210  =   1x frei
   'File 211  =   Montag
   'File 212  =   Dienstag
   'File 213  =   Mittwoch
   'File 214  =   Donnerstag
   'File 215  =   Freitag
   'File 216  =   Samstag
   'File 217  =   Sonntag
   'File 220-243 = 0Uhr bis 23Uhr
   'File 244-255 = frei

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 


 

Nach oben