So, Danke mal für die Antwort.
Jetzt schaut mein Code so aus:
Aber fahren tut er trotzdem nicht.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
Wenn ich die Pins aber einzeln abfrage, also so:
Dann gehts. Nur kann ich dann logischerweise den Portc nicht in Abhängigkeit von zwei Pins vom PortA ansteuern.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
Verstehst du?







Zitieren
Lesezeichen