So, jetzt funktioniert soweit alles. Ich brauche jetzt nur noch eine Richtige Spannungsversorgung etc.

Wenn's interessiert, hier der Code:
Code:
$regfile "m16def.dat"
$crystal = 16000000
$baud = 9600
$swstack = 16
$hwstack = 16
$framesize = 16

Dim A As Word
Dim B As Word
Dim C As Word
Dim X As Word
Dim Y As Word
Dim Z As Word

Config Porta.4 = Output
Config Porta.5 = Output
Config Porta.6 = Output
Config Portc.7 = Output
Config Portc.6 = Output
Config Portc.5 = Output
Config Portb.2 = Output

M1 Alias Porta.5
M2 Alias Porta.6
M3 Alias Portc.6
M4 Alias Portc.5

Config Servos = 1 , Servo1 = Portb.2 , Reload = 10
Config Adc = Single , Prescaler = Auto , Reference = Avcc
Start Adc
Config Timer1 = Pwm , Pwm = 10 , Compare A Pwm = Clear Down , Compare B Pwm = Clear Down , Prescale = 1

Enable Interrupts

Servo(1) = 100
Wait 1

Do

Pwm1a = 64
Pwm1b = 64

A = Getadc(1)
B = Getadc(2)
C = Getadc(3)

If A > 200 Then
Gosub Brems
Waitms 500
Gosub Way
Waitms 100
Else
Gosub Vor
End If

If B > 200 Then
Gosub Brems
Waitms 500
Gosub Way
Waitms 100
Else
Gosub Vor
End If

If C > 200 Then
Gosub Brems
Waitms 500
Gosub Way
Waitms 100
Else
Gosub Vor
End If

Loop

Vor:
M1 = 0
M2 = 1
M3 = 0
M4 = 1
Return

Rueck:
M1 = 1
M2 = 0
M3 = 1
M4 = 0
Return

Brems:
M1 = 1
M2 = 1
M3 = 1
M4 = 1
Return

Rueckr:
M1 = 1
M2 = 0
M3 = 0
M4 = 0
Return

Rueckl:
M1 = 0
M2 = 0
M3 = 1
M4 = 0
Return

Vorr:
M1 = 0
M2 = 1
M3 = 0
M4 = 0
Return

Vorl:
M1 = 0
M2 = 0
M3 = 0
M4 = 1
Return

Way:
Servo(1) = 150
Waitms 300
Y = Getadc(2)
Waitms 300
Servo(1) = 50
Waitms 300
Z = Getadc(2)
Waitms 300

If Y > Z Then
Gosub Vorl
Waitms 500
Gosub Brems
Waitms 300
Gosub Vor
End If

If Y < Z Then
Gosub Vorr
Waitms 500
Gosub Brems
Waitms 300
Gosub Vor
End If
Servo(1) = 100
Return

End

Danke an Alle.


Mfg JeyBee