Es ist mir peinlich, aber ich habe echt keine Ahnung
Code:
Declare Sub Motor1()
Declare Sub Motor2()
Declare Sub Motor3()
Declare Sub Motor4()
Declare Function Joystickabfrage() As Byte
$regfile = "m32def.dat"
$framesize = 32
$swstack = 32
$hwstack = 32
Dim I As Integer
Dim N As Integer
Dim Ton As Integer
$crystal = 16000000 'Quarzfrequenz
$baud = 9600
Config Porta = Input
Config Adc = Single , Prescaler = Auto 'Für Tastenabfrage und Spannungsmessung
Dim Joy1x As Word 'Variablen für Positionen der JoyPad Steuerknüppel
Dim Joy1y As Word
Start Adc
'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
I = 0
Sound Portd.7 , 400 , 450 'BEEP
Sound Portd.7 , 400 , 250 'BEEP
Sound Portd.7 , 400 , 450 'BEEP
Print
Print "**** RN-Control 1.4 *****"
Print "Das neue Experimentier- und Roboterboard"
Print "Weitere passende Zusatzboards bei www.robotikhardware.de"
Print
Function Joystickabfrage() As Byte
Do
Joy1y = Getadc(0)
Joy1x = Getadc(1)
Print "Joystick 1 Position: X=" ; Joy1x ; " Y=" ; Joy1y
Wait 2
Loop
End Function
'Motoren und Geschwindigkeitsreglung
Sub Motor1()
'Rechter Motor ein
Portb.0 = 1 'bestimmt Richtung rechter Motor
Portb.1 = 0 'bestimmt Richtung rechter Motor
Portd.5 = 1 'rechter Motor EIN
I = 0
Do
Pwm1a = 0
Pwm1b = I
Waitms 5
I = I + 10
Loop Until I > 300
Wait 1
Do
Pwm1a = 0
Pwm1b = I
Waitms 5
I = I - 10
Loop Until I < 1
Pwm1a = 0 'Linker Motor aus
Pwm1b = 0 'rechter Motor aus
End Sub
'Motoren und Geschwindigkeitsreglung
Sub Motor2()
'Rechter Motor ein
Portc.0 = 0 'bestimmt Richtung
Portc.1 = 1 'bestimmt Richtung
Portd.5 = 1 'rechter Motor EIN
I = 0
Do
Pwm1a = 0
Pwm1b = I
Waitms 5
I = I + 10
Loop Until I > 300
Wait 1
Do
Pwm1a = 0
Pwm1b = I
Waitms 5
I = I - 10
Loop Until I < 1
Pwm1a = 0 'Linker Motor aus
Pwm1b = 0 'rechter Motor aus
End Sub
'Motoren und Geschwindigkeitsreglung
Sub Motor3()
'Linker Motor ein
Portb.6 = 0 'bestimmt Richtung rechter Motor
Portb.7 = 1 'bestimmt Richtung rechter Motor
Portd.4 = 1 'linker Motor EIN
I = 0
Do
Pwm1a = I
Pwm1b = 0
Waitms 5
I = I + 10
Loop Until I > 300
Wait 1
Do
Pwm1a = I
Pwm1b = 0
Waitms 5
I = I - 10
Loop Until I < 1
Pwm1a = 0 'Linker Motor aus
Pwm1b = 0 'rechter Motor aus
End Sub
'Motoren und Geschwindigkeitsreglung
Sub Motor4()
'Linker Motor ein
Portc.6 = 1 'bestimmt Richtung
Portc.7 = 0 'bestimmt Richtung
Portd.4 = 1 'Linker Motor EIN
I = 0
Do
Pwm1a = I
Pwm1b = 0
Waitms 5
I = I + 10
Loop Until I > 300
Wait 1
Do
Pwm1a = I
Pwm1b = 0
Waitms 5
I = I - 10
Loop Until I < 1
Pwm1a = 0 'Linker Motor aus
Pwm1b = 0 'rechter Motor aus
End Sub
Lesezeichen