hallo allerseits.

ich taste mich zur zeit ganz langsam an den zero und python ran. Mein momentanes wissen reicht dazu folgenden code halbwegs zu verstehen, ihn über vnc und geany zu starten (das fliegermodell) und zu beenden (der rote punkt).

Code:
# https://cdn.shopify.com/s/files/1/0176/3274/files/MotoZero_User_Guide_1.2.pdf

from RPLCD.i2c import CharLCD

from gpiozero import Motor, OutputDevice   
from time import sleep
from gpiozero import Button   

lcd = CharLCD('PCF8574', 0x3f)

pin_a_HL = Button(19,pull_up=True)         # Rotary encoder pin A connected to GPIO19
pin_b_HL = Button(26,pull_up=True)         # Rotary encoder pin B connected to GPIO26

def pin_a_HL_rising():                    # Pin A event handler
    if pin_b_HL.is_pressed: print("-1")   # pin A rising while A is active is a clockwise turn

def pin_b_HL_rising():                    # Pin B event handler
    if pin_a_HL.is_pressed: print("1")   # pin B rising while A is active is a clockwise turn

#pin_a_HL.when_pressed = pin_a_HL_rising      # Register the event handler for pin A
#pin_b_HL.when_pressed = pin_b_HL_rising      # Register the event handler for pin B



motor_VL = Motor(24, 27)   
motor_VL_enable = OutputDevice(5, initial_value=1)   
motor_VR = Motor(6, 22)   
motor_VR_enable = OutputDevice(17, initial_value=1) 
motor_HR = Motor(23, 16)   
motor_HR_enable = OutputDevice(12, initial_value=1)    
motor_HL = Motor(13, 18)   
motor_HL_enable = OutputDevice(25, initial_value=1)   



def vorwaerts():
    lcd.clear()
    motor_VL.forward(0.5)  
    motor_VR.forward(0.5)  
    motor_HR.forward(0.5)  
    motor_HL.forward(0.5)  
    lcd.write_string('vorwaerts')
    pin_a_HL.when_pressed = pin_a_HL_rising
    pin_b_HL.when_pressed = pin_b_HL_rising
    sleep(2)

def rueckwaerts():
    lcd.clear()
    motor_VL.backward(0.5)  
    motor_VR.backward(0.5)  
    motor_HR.backward(0.5)  
    motor_HL.backward(0.5)  
    lcd.write_string('rueckwaerts')
    sleep(2)


def drehe_links():
    lcd.clear()
    motor_VL.backward(0.5) 
    motor_VR.forward(0.5)  
    motor_HR.forward(0.5)  
    motor_HL.backward(0.5) 
    lcd.write_string('drehe links')
    sleep(2)

def drehe_rechts():
    lcd.clear()
    motor_VL.forward(0.5)  
    motor_VR.backward(0.5) 
    motor_HR.backward(0.5) 
    motor_HL.forward(0.5)  
    lcd.write_string('drehe rechts')
    sleep(2)

def schiebe_links():
    lcd.clear()
    motor_VL.backward(0.5) 
    motor_VR.forward(0.5) 
    motor_HR.backward(0.5)  
    motor_HL.forward(0.5)  
    lcd.write_string('schiebe links')
    sleep(2)

def schiebe_rechts():
    lcd.clear()
    motor_VL.forward(0.5) 
    motor_VR.backward(0.5) 
    motor_HR.forward(0.5)  
    motor_HL.backward(0.5)  
    lcd.write_string('schiebe rechts')
    sleep(2)

def ende():
    lcd.clear()
    lcd.write_string('stop')
    sleep(2)
    lcd.clear()

while True:
    vorwaerts()

    rueckwaerts()

    drehe_links()

    drehe_rechts()

    schiebe_links()

    schiebe_rechts()

    ende()
beim beenden des codes drehen sich manchmal zwei, manchmal aber auch drei oder eines der vier räder einfach weiter. Wie verhindere ich das ohne den zero ab- und wieder anzuschalten? Das booten ist sehr lästig...