Danke Radbruch, jetzt hat's geklappt.

Der Vollständigkeit halber noch der richtige Code:
Code:
'Verwendeter Compiler Bascom V 1.11.9.7
'
'Aufgabe:
'NIBOBee fällt nicht vom Tisch
'Autor: Pinsel120866
'###################################################

$regfile = "m16def.dat"
$crystal = 15000000
$hwstack = 32
$swstack = 8
$framesize = 24

Lineled Alias Portb.4

Config Portd.4 = Output                                     ' pmw_r
Config Portd.5 = Output                                     ' pwm_l
Config Portd.6 = Output                                     ' dir_l
Config Portd.7 = Output                                     ' dir_r
Config Lineled = Output                                     ' Lineled
Config Adc = Single , Prescaler = 64 , Reference = Avcc     ' 235 kHz
Config Timer1 = Pwm , Pwm = 10 , Compare A Pwm = Clear Up , Compare B Pwm = Clear Up , Prescale = 1

Declare Sub Motorpwm(byval Pwm_l As Byte , Byval Pwm_r As Byte)
Declare Sub Motordir(byval Dir_l As Byte , Byval Dir_r As Byte)
Declare Sub Frontled(byval Ledstatus As Byte)
Declare Sub Linedata()

Dim Linesensl As Integer
Dim Linesensc As Integer
Dim Linesensr As Integer
Dim _lcd_e As Byte                                          'Needed to control 4 line LCD
Enable Interrupts

Start Adc
$lib "Lcd_i2c_DOGM.lib"                                     'I2c driver for the LCD
Config I2cdelay = 1
Const Pcf8574_lcd = &H4E                                    'Defines the address of the I/O expander for LCD
Config Scl = Portc.0                                        'Configure I2C SCL
Config Sda = Portc.1                                        'Configure I2C SDA
Config Lcd = 16 * 3 , Chipset = Dogm163v5    '16*3 type LCD display 5V

I2cstart

Call Linedata

_lcd_e = 128                                                'Upper half of 4-line display is selected
Cls                                                         'clear the LCD display
Lcd "*Liniensensoren*"                                      'display this at the top line
Waitms 1
Lowerline                                                   'select the lower line
Lcd "R-" ; Linesensr ; " M-" ; Linesensc ; " L-" ; Linesensl
Waitms 1                                                    'display this at the lower line
_lcd_e = 64                                                 'Lower half of 4-line display is selected
Lcd "nix"
Waitms 1
Lowerline
Lcd "nix"

Wait 3

Do

   Call Frontled(0)
   Waitms 10
   Call Linedata
      _lcd_e = 128                                          'Upper half of 4-line display is selected
      Cls                                                         'clear the LCD display
      Lcd "*Liniensensoren*"                                      'display this at the top line
      Waitms 1
      Lowerline                                                   'select the lower line
      Lcd "R-" ; Linesensr ; " M-" ; Linesensc ; " L-" ; Linesensl
      Waitms 1                                                    'display this at the lower line
      _lcd_e = 64                                                 'Lower half of 4-line display is selected
      Lcd "nix"
      Waitms 1
      Lowerline
      Lcd "nix"

   Waitms 10

   If Linesensc < 7 Or Linesensr < 12 Or Linesensl < 22 Then       'hier anpassen!
      Call Motordir(0 , 0)
      Call Motorpwm(0 , 0)
      Waitms 500
      Call Motordir(0 , 0)
      Call Motorpwm(100 , 100)
      Waitms 500
      Call Motordir(1 , 0)
      Call Motorpwm(100 , 100)
      Waitms 500
      Call Motordir(1 , 1)
      Call Motorpwm(100 , 100)

   Else
      Call Motordir(1 , 1)
      Call Motorpwm(100 , 100)

   End If
   Loop
End

Sub Motorpwm(byval Pwm_l As Byte , Byval Pwm_r As Byte)
   Pwm1a = Pwm_l * 4
   Pwm1b = Pwm_r * 4
End Sub

Sub Motordir(byval Dir_l As Byte , Byval Dir_r As Byte)
   If Dir_l = 0 Then Portd.6 = 0 Else Portd.6 = 1
   If Dir_r = 0 Then Portd.7 = 1 Else Portd.7 = 0
End Sub

Sub Frontled(byval Ledstatus As Byte)                       ' LED für Liniensensor ein-/aus-schalten
  Ddrb.4 = 1
  Portb.4 = Ledstatus.0
End Sub

Sub Linedata()                                              ' Liniensensoren lesen
   Config Portb.4 = Output
   Portb.4 = 1
   Linesensl = Getadc(5)
   Linesensc = Getadc(6)
   Linesensr = Getadc(7)
   Portb.4 = 0
End Sub
Sind bei euch die 3 Liniensensor-Werte auch so unterschiedlich?