hallo;
danke für die antwort!
ok jetzt mein programm.
Declare Sub 1()
Declare Sub 2()
Declare Sub Motor()
Declare Sub Motor2()



$regfile = "m32def.dat"

Dim I As Integer
Dim N As Integer
Dim Z As Integer
Dim H As Integer
Dim Sen As Byte

$crystal = 16000000 'Quarzfrequenz
$baud = 9600

Config Porta.7 = 1 'Pullup Widerstand ein




Const Ref = 7.5 / 1023 'Für Batteriespannungsberechnung

Dim Taste As Byte
Dim Volt As Single

Config Pina.0 = Input
Config Pina.1 = Input
Config Pina.2 = Input
Config Pinc.6 = Output 'Linker Motor Kanal 1
Config Pinc.7 = Output 'Linker Motor Kanal 2
Config Pind.4 = Output 'Linker Motor PWM
'Ports für rechten Motor
Config Pinb.0 = Output 'Rechter Motor Kanal 1
Config Pinb.1 = Output 'Rechter Motor Kanal 2
Config Pind.5 = Output 'Rechter Motor PWM
Config Timer1 = Pwm , Pwm = 10 , Compare A Pwm = Clear Down , Compare B Pwm = Clear Down
Pwm1a = 0
Pwm1b = 0
Tccr1b = Tccr1b Or &H02 'Prescaler = 8
Waitms 200
Gosub 1
Sub 1()
Portc.6 = 0 'bestimmt Richtung
Portc.7 = 1 'bestimmt Richtung
Portd.4 = 0 'Linker Motor EIN

'Rechter Motor ein
Portb.0 = 1 'bestimmt Richtung rechter Motor
Portb.1 = 0 'bestimmt Richtung rechter Motor
Portd.5 = 1


If Pina.0 = 1 And Pina.1 = 1 And Pina.2 = 1 Then 'starte die motoren
Do
Pwm1a = 1023
Pwm1b = 1023
Loop
End If


If Pina.0 = 0 And Pina.1 = 1 And Pina.2 = 1 Then 'wenn linker sensor etwas sieht dann abdrehen nach rechts
Do
Pwm1a = 0
Pwm1b = 1023
Loop Until Pina.0 = 1
End If


If Pina.1 = 0 And Pina.0 = 1 And Pina.2 = 1 Then ' wenn rechter sensor etwas sieht dann abdrehen nach links
Do
Pwm1a = 1023
Pwm1b = 0
Loop Until Pina.1 = 1
End If

If Pina.0 = 0 And Pina.2 = 0 And Pina.1 = 1 Then 'wenn linker und mittlerer sensor etwas sehen abdrehen nach rechts
Do
Pwm1a = 0
Pwm1b = 1023
Loop Until Pina.0 = 1 And Pina.2 = 1 'solange abdrehen bis sie beide nichtsmehr sehen
End If

If Pina.2 = 0 And Pina.1 = 0 And Pina.0 = 1 Then 'wenn rechter und mittlerer sensor etwas sieht dann abdrehen nach rechts
Do
Pwm1a = 1023
Pwm1b = 0
Loop Until Pina.2 = 1 And Pina.1 = 1 'solange bis sie beide nichtsmehr sehen
End If
Gosub 1
End Sub

was muss ich programmieren, dass wenn er nur kurz bei allen drei Sensoren etwas erkennt eine 90 crad drehung macht.
mfg
elektropro
http://www.david-schleicher.de/