$regfile = "m88def.dat"
$crystal = 8000000

'Config Lcd stelt de Lcd poort pinnen in
Config Lcdpin = Pin , Db4 = Portb.2 , Db5 = Portb.3 , Db6 = Portb.4 , Db7 = Portb.5 , E = Portb.1 , Rs = Portb.0
Config Lcdbus = 4                                           'Selecteer 4 bits mode
Config Lcd = 16 * 2                                         '16*2 type LCD display
'U kunt uw eigen LCD karakters maken met het Deflcdchar commando
'Gebruik hiervoor de Bascom LCD Designer, Tools -> LCD Designer menu
Cursor Off Noblink                                          'Geen cursor
                                       'Geen cursor

Cls                                                         'Dit maakt het scherm leeg

  Config Portc.1 = Output                                   'plc
  Config Portc.2 = Output                                   'rood knipper led
  Config Portc.3 = Output                                   'relais R3 (schuif  omhoog)
  Config Portc.4 = Output                                   'Relais R4  (schuif omlaag)
  Config Portc.5 = Output                                   'groen knipperled
  Config Portc.0 = Output                                   'bascom 2

  Config Portd.1 = Input                                    'start signaal
  Config Portd.2 = Input                                    'relais R1   (hefarm omlaag)
  Config Portd.3 = Input                                    'relais R2   (hefarm omhoog)
  Config Portd.4 = Input                                    'schakelaar S1
  Config Portd.5 = Input                                    'relais R3
  Config Portd.0 = Input                                    'relais R4





  Do
    Gosub Startsignaal
  Gosub Command
  Gosub Knipperled
  Gosub Relais1
  Gosub Relais2
  Gosub Relaisr3
  Gosub Groenknipperled
  Gosub Relaisr4
  Gosub Groenknipperled2
  Gosub Bascom2
  Loop



  Startsignaal:

 Locate 1 , 1 : Lcd "startsignaal"
  Waitms 500
  Cls
  Do
  If Portc.1 = 1 Then Return
  Loop

  Command:
  Locate 1 , 1 : Lcd "command"
  Waitms 500
  Cls
  Do
  If Portd.1 = 1 Then Goto Knipperled
  Loop

Knipperled:

  Locate 1 , 1 : Lcd "rood knipper"
  Locate 2 , 1 : Lcd "led"
  Waitms 500
  Set Portc.2
  Waitms 500
  Reset Portc.2
  Return

    Relais1:
  Locate 1 , 1 : Lcd "relais 1"
  Waitms 500
  Cls
  Do
  If Portd.2 = 1 Then Goto Relais2
  Loop

  Relais2:
  Locate 1 , 1 : Lcd "Relais2"
  Waitms 500
  Cls
  Do
  If Portd.3 = 1 Then Goto Knipperled
  Loop

  Relaisr3:

  Locate 1 , 1 : Lcd "relais R3"
  Set Portc.3
  Waitms 500
  Reset Portc.3
  Waitms 500
  Cls
  Return

  Groenknipperled:

  Locate 1 , 1 : Lcd "groene"
  Locate 2 , 1 : Lcd "led"
  Set Portc.5
  Waitms 500
  Cls
  Return


  Relaisr4:

  Locate 1 , 1 : Lcd "relais R3"
  Set Portc.4
  Wait 2
  Reset Portc.4
  Waitms 500
  Cls
  Return

   Groenknipperled2:

   Locate 1 , 1 : Lcd "reset"
   Locate 2 , 1 : Lcd "led"
   Reset Portc.5
   Waitms 500
   Cls
   Return

   Bascom2:

   Locate 1 , 1 : Lcd "signaal 2"
   Locate 2 , 1 : Lcd "bascom 2"
   Set Portc.0
   Waitms 500
   Reset Portc.0
   Cls
   Return



    End