Ok, danke für den tipp, ich hab den Code noch mal überarbeitet. So müsste es doch jetzt
stimmen oder???Code:' Schalter hinten =PC6 ' Enable Motor1 = PA=0 ' Motor1 Eingang A = PA1 ' Motor1 Eingang B = PA2 ' Enable Motor2 = PA4 ' Motor2 Eingang A = PA5 ' Motor2 Eingang B = PA6 $regfile = "m32def.dat" $framesize = 32 $swstack = 32 $hwstack = 32 $crystal = 1000000 Config Porta.0 = Output Config Porta.1 = Output Config Porta.2 = Output Config Porta.4 = Output Config Porta.5 = Output Config Porta.6 = Output Config Pinc.0 = Input Config Pinc.6 = Input Portc.0 = 1 Portc.6 = 1 Do If Pinc.0 = 1 Then 'Wenn keine kolision (vorne) erfolgt Porta.0 = 1 'fahre vorwärts. Porta.4 = 1 Porta.1 = 1 Porta.5 = 1 End If If Pinc.0 = 0 Then 'Wenn kollision (vorne) erfolgt, Porta.1 = 0 'Bremse, Porta.2 = 0 Porta.5 = 0 Porta.6 = 0 Waitms 20 'warte 20 ms Porta.1 = 1 'Drehe 200ms Porta.2 = 0 Porta.5 = 0 Porta.6 = 1 Waitms 200 Porta.1 = 0 'Bremse Porta.2 = 0 Porta.5 = 0 Porta.6 = 0 Waitms 20 'warte 20ms End If If Pinc.6 = 1 Then ' Wenn keine kolision (hinten) Porta.0 = 1 'fahre vorwärts Porta.4 = 1 Porta.1 = 1 Porta.5 = 1 End If If Pinc.6 = 0 Then 'Wenn kolision (hinten) Porta.1 = 0 'Bremse, Porta.2 = 0 Porta.5 = 0 Porta.6 = 0 Waitms 20 'warte 20 ms Porta.1 = 1 'drehe 200ms Porta.2 = 0 Porta.5 = 0 Porta.6 = 1 Waitms 200 Porta.1 = 0 'Bremse Porta.2 = 0 Porta.5 = 0 Porta.6 = 0 Waitms 20 'warte 20 ms End If Loop End







Zitieren

Lesezeichen