Ich hab den Code noch mal geupdatet
Code:
'Programm zur Linienverfolgung mit 3 CNY70 IR-SENSOREN
'Lenkservo:
Config Servos = 1 , Servo1 = Portd.4 , Reload 20
Config Adc = Single , Prescaler = Auto ' Nicht Sicher
'Lenkservo-Port
Config Portd.4 = Output
Portd.4 = Y
'Motor:
Config Pind.5 = Output
Portd.5 = X
'CNY70 links
Config Porta.1 = Input
Porta.1 = Links
'CNY70 mitte
Config Porta.2 = Input
Porta.2 = Mitte
'CNY70 rechts
Config Porta.3 = Input
Porta.3 = Rechts
Enable Interrupts
Dim X As Bit
Dim Y As Integer
Dim Links As Integer
Dim Mitte As Integer
Dim Rechts As Integer
' Voreinstellungen:
'-Motor aus
'-Servo Mittelstellung
X = 0
Y = 100
'Taster an portA.0
'Warten bis Taster gesetzt:
Bitwait Pina.0 , Set
'Motor ein:
X = 1
Do
If Links = 1 And Mitte = 0 And Rechts = 1 Then
Goto Gerade
If Links = 1 And Mitte = 1 And Rechts = 0 Then
Goto Rechts
If Links = 0 And Mitte = 1 And Rechts = 1 Then
Goto Links
If Links = 0 And Mitte = 0 And Rechts = 1 Then
Goto Halblinks
If Links = 1 And Mitte = 0 And Rechts = 0 Then
Goto Halbrechts
End If
Loop Until Pina.0 , Reset
Gerade:
Y = 100
Rechts:
Y = 150
Links:
Y = 50
Halblinks:
Y = 75
Halbrechts:
Y = 125
Lesezeichen