Hi

Habs nun nachn bischen probieren und nochmal komplett neu schreiben hinbekommen.

Code:
define LIGHT       as port[16]
define BPORT1   as byteport[1]

import "...\LIB\SHOW_BINARY.BAS"
import "...\LIB\PULLUP1_ENABLE.BAS"

define ADC8           ad[8]

define SDA          as port[9]
define SCL          as port[10]
define EXTPORT      as byteport[4]

define STATION_IO   as  byte[3]

define REL1         as  bit [21]
define REL2         as  bit [22]
define REL3         as  bit [23]
define REL4         as  bit [24]

PULLUP1_ENABLE()
LIGHT=off
LCD.INIT
SDA=on
SCL=on
STATION_IO=OFF
#HAUPTSCHLEIFE


EXTPORT=STATION_IO
LCD.POS 1,1
LCD.PRINT "BINARY: " 
SHOW_BINARY(BPORT1)

'--- D1 - D4 ---

if (BPORT1 = 11111110b) then
 Do
 Loop Until BPORT1 <> 11111110b
 if ( REL1 = OFF) then
  REL1 = ON
  EXTPORT=STATION_IO
  goto HAUPTSCHLEIFE
 end if
 if ( REL1 = ON) then
  REL1 = OFF
  EXTPORT=STATION_IO
  goto HAUPTSCHLEIFE
 end if
 goto HAUPTSCHLEIFE
end if
if (BPORT1 = 11111101b) then
 Do
 Loop Until BPORT1 <> 11111101b
 if ( REL2 = OFF) then
  REL2 = ON
  EXTPORT=STATION_IO
  goto HAUPTSCHLEIFE
 end if
 if ( REL2 = ON) then
  REL2 = OFF
  EXTPORT=STATION_IO
  goto HAUPTSCHLEIFE
 end if
 goto HAUPTSCHLEIFE
end if
if (BPORT1 = 11111011b) then
 Do
 Loop Until BPORT1 <> 11111011b
 if ( REL3 = OFF) then
  REL3 = ON
  EXTPORT=STATION_IO
  goto HAUPTSCHLEIFE
 end if
 if ( REL3 = ON) then
  REL3 = OFF
  EXTPORT=STATION_IO
  goto HAUPTSCHLEIFE
 end if
 goto HAUPTSCHLEIFE
end if
if (BPORT1 = 11110111b) then
 Do
 Loop Until BPORT1 <> 11110111b
 if ( REL4 = OFF) then
  REL4 = ON
  EXTPORT=STATION_IO
  goto HAUPTSCHLEIFE
 end if
 if ( REL4 = ON) then
  REL4 = OFF
  EXTPORT=STATION_IO
  goto HAUPTSCHLEIFE
 end if
end if

'--- D5 - D8 ---

if (BPORT1 = 11101111b) then
 Do
 Loop Until BPORT1 <> 11101111b
 if ( REL1 = OFF) then
  REL1 = ON
  EXTPORT=STATION_IO
  goto HAUPTSCHLEIFE
 end if
 if ( REL1 = ON) then
  REL1 = OFF
  EXTPORT=STATION_IO
  goto HAUPTSCHLEIFE
 end if
 goto HAUPTSCHLEIFE
end if
if (BPORT1 = 11011111b) then
 Do
 Loop Until BPORT1 <> 11011111b
 if ( REL2 = OFF) then
  REL2 = ON
  EXTPORT=STATION_IO
  goto HAUPTSCHLEIFE
 end if
 if ( REL2 = ON) then
  REL2 = OFF
  EXTPORT=STATION_IO
  goto HAUPTSCHLEIFE
 end if
 goto HAUPTSCHLEIFE
end if
if (BPORT1 = 10111111b) then
 Do
 Loop Until BPORT1 <> 10111111b
 if ( REL3 = OFF) then
  REL3 = ON
  EXTPORT=STATION_IO
  goto HAUPTSCHLEIFE
 end if
 if ( REL3 = ON) then
  REL3 = OFF
  EXTPORT=STATION_IO
  goto HAUPTSCHLEIFE
 end if
 goto HAUPTSCHLEIFE
end if
if (BPORT1 = 01111111b) then
 Do
 Loop Until BPORT1 <> 01111111b
 if ( REL4 = OFF) then
  REL4 = ON
  EXTPORT=STATION_IO
  goto HAUPTSCHLEIFE
 end if
 if ( REL4 = ON) then
  REL4 = OFF
  EXTPORT=STATION_IO
  goto HAUPTSCHLEIFE
 end if
end if
goto HAUPTSCHLEIFE