stimmt nun jetzt habe ich schon wieder ein neues problem
ICh will das der roboter rum fährt und sobald er einem hindernis näher kommt so er abbremsen und ausweichen...
meine frage ist jetzt wie progge ich das
denke mal I ist dann eine varibale die immer weniger wird
I = 700
I = 600
....
aber wie mache ich das denn wenn es in der schleife läuft dann ist die spannung nicht immer konstant ...
hoffe ihr versteht mein problem...
wie mache ich sowas
If A > 65 Then Portc.7 = 1 Else Portc.7 = 0 I = 100 K= 1023
If A > 140 Then Portc.6 = 1 Else Portc.6 = 0 I = 200 K= 1023
If A > 180 Then Portc.5 = 1 Else Portc.5 = 0 I = 350K= 1023
If A > 220 Then Portc.4 = 1 Else Portc.4 = 0 I = 450 K= 1023
If A > 270 Then Portc.3 = 1 Else Portc.3 = 0 I = 550 K= 1023
If A > 350 Then Portc.2 = 1 Else Portc.2 = 0 I = 700 K= 1023
If A > 400 Then Portc.1 = 1 Else Portc.1 = 0 I = 900 K= 1023
If A > 530 Then Portc.0 = 1 Else Portc.0 = 0 I = 1023 K= 1023
Pwm1a = I
Pwm1b = K
Das ich deklarieren muss ist klar doch zeigt er mir immer fehler an denke muss irgenwie logisch verknüpft werden plz help me
Danke ihr seit echt super Greetz linux
Code:$regfile = "m32def.dat" $crystal = 16000000 ' Für Motorentest 'Ports für linken Motor Config Pinc.6 = Output 'Linker Motor Kanal 1 Config Pinc.7 = Output 'Linker Motor Kanal 2 Config Pind.4 = Output 'Linker Motor PWM 'Ports für rechten Motor Config Pinb.0 = Output 'Rechter Motor Kanal 1 Config Pinb.1 = Output 'Rechter Motor Kanal 2 Config Pind.5 = Output 'Rechter Motor PWM Config Timer1 = Pwm , Pwm = 10 , Compare A Pwm = Clear Down , Compare B Pwm = Clear Down Pwm1a = 0 Pwm1b = 0 Tccr1b = Tccr1b Or &H02 'Prescaler = 8 'ADC Config Porta = Input Config Portc = Output Config Adc = Single , Prescaler = Auto Dim A As Word 'Linker Motor ein Portc.6 = 1 'bestimmt Richtung Portc.7 = 0 'bestimmt Richtung Portd.4 = 1 'Linker Motor EIN 'Rechter Motor ein Portb.0 = 1 'bestimmt Richtung rechter Motor Portb.1 = 0 'bestimmt Richtung rechter Motor Portd.5 = 1 'rechter Motor EIN Enable Interrupts Start Adc Do '1 = aus '0 = an A = Getadc(0) If A > 65 Then Portc.7 = 1 Else Portc.7 = 0 If A > 140 Then Portc.6 = 1 Else Portc.6 = 0 If A > 180 Then Portc.5 = 1 Else Portc.5 = 0 If A > 220 Then Portc.4 = 1 Else Portc.4 = 0 If A > 270 Then Portc.3 = 1 Else Portc.3 = 0 If A > 350 Then Portc.2 = 1 Else Portc.2 = 0 If A > 400 Then Portc.1 = 1 Else Portc.1 = 0 If A > 530 Then Portc.0 = 1 Else Portc.0 = 0 Pwm1a = 1023 Pwm1b = 512 Waitms 1 Loop End







Zitieren

Lesezeichen