Hi,
ich möchte mit 2 Taster die Geschwindigkeit von 2 Motoren (die an einemL298 hängen) verändern. Also beim 1 Taster schneller bis zum Maximum und beim anderen halt langsamer bis zum stillstand.
Irgendwie klappt das nicht und ich finde keinen Fehler, wäre schön wenn mir jemand helfen könnte Bild  
Code:
$regfile = "m16def.dat"
$crystal = 16000000
$baud = 9600
Config Timer1 = Pwm , Pwm = 8 , Compare A Pwm = Clear Up , Compare B Pwm = Clear Up , Prescale = 64
Config Pina.0 = Output                                      'Input 1
Config Pina.1 = Output                                      'Input 2
Config Pina.2 = Output                                      'Input 3
Config Pina.3 = Output                                      'Input 4
Config Pind.4 = Output
Config Pind.5 = Output
Config Pind.6 = Input
Portd.6 = 1
Config Pind.7 = Input
Portd.7 = 1
Compare1a = 5
Compare1b = 5
Do
Porta.0 = 1
Porta.1 = 0
Porta.2 = 1
Porta.3 = 0
If Pind.6 = 0 Then
Compare1a = Compare1a + 1
Compare1b = Compare1b + 1
End If
If Pind.7 = 0 Then
Compare1a = Compare1a - 1
Compare1b = Compare1b - 1
End If
If Compare1a < 0 Then
Compare1a = 0
End If
If Compare1b < 0 Then
Compare1b = 0
End If
If Compare1a > 255 Then
Compare1a = 255
End If
If Compare1b < 255 Then
Compare1b = 255
End If