So, Danke mal für die Antwort.
Jetzt schaut mein Code so aus:
Code:
Rem Portc.0 = 1 --> Motor links vor
Rem Portc.1 = 1 --> Motor links rück
Rem Portc.2 = 1 --> Motor rechts vor
Rem Portc.3 = 1 --> Motor rechts rück
Rem Sensor links --> Porta.0 (sw =1)
Rem Sensor rechts --> Porta.1 (sw =1)
$regfile = "m32def.dat"
$crystal = 4000000
$baud = 9600
Config Portc = Output
Config Porta = Input
Do
If Pina = 0 Then
Portc.0 = 1
Portc.1 = 0
Portc.2 = 1
Portc.3 = 0
End If
If Pina = 1 Then
Portc.0 = 0
Portc.1 = 0
Portc.2 = 1
Portc.3 = 0
End If
If Pina = 2 Then
Portc.0 = 1
Portc.1 = 0
Portc.2 = 0
Portc.3 = 0
End If
If Pina = 3 Then
Portc.0 = 1
Portc.1 = 0
Portc.2 = 1
Portc.3 = 0
End If
Loop
Aber fahren tut er trotzdem nicht.
Wenn ich die Pins aber einzeln abfrage, also so:
Code:
Do
If Pina.0 = 0 Then
Portc.0 = 1
Portc.1 = 0
Portc.2 = 1
Portc.3 = 0
End If
If Pina.0 = 1 Then
Portc.0 = 0
Portc.1 = 0
Portc.2 = 1
Portc.3 = 0
End If
If Pina.1 = 2 Then
Portc.0 = 1
Portc.1 = 0
Portc.2 = 0
Portc.3 = 0
End If
If Pina.1 = 3 Then
Portc.0 = 1
Portc.1 = 0
Portc.2 = 1
Portc.3 = 0
End If
Loop
Dann gehts. Nur kann ich dann logischerweise den Portc nicht in Abhängigkeit von zwei Pins vom PortA ansteuern.
Verstehst du?
Lesezeichen