# loading libs
from machine import Pin, PWM
from time import sleep
import tm1637
# define pins
servo_pin_l = 1
servo_pin_r = 0
pwm_l = PWM(Pin(servo_pin_l))
pwm_r = PWM(Pin(servo_pin_r))
pwm_l.freq(50)
pwm_r.freq(50)
button_l_plus = Pin(7, Pin.IN, Pin.PULL_UP)
button_l_minus = Pin(6, Pin.IN, Pin.PULL_UP)
button_r_plus = Pin(27, Pin.IN, Pin.PULL_UP)
button_r_minus = Pin(26, Pin.IN, Pin.PULL_UP)
# define some positions might be useful
# 0 degrees
deg000 = 570000
# 90 degrees
deg090 = 1470000
# 180 degrees
deg180 = 2370000 
# defining position and step
pos_l = deg000
pos_r = deg180
step = 100000 # works fine here
# start positionen anfahren
pwm_l.duty_ns(deg000)
pwm_r.duty_ns(deg180)
display = tm1637.TM1637(clk=machine.Pin(16), dio=machine.Pin(17))
#display.scroll("Pico Turner", delay=200)
sleep(1)
display.show('    ')
sleep(1)
wl = (deg090 / 10000) - ((deg090 - pos_l) / 10000) - 57  #pos stimmt, aber nicht winkel in grad, sondern in time_ns / 10000
wr = (deg090 / 10000) - ((pos_r - deg090) / 10000) - 57
winkel_l = int(wl) 
winkel_r = int(wr)
display.numbers(winkel_l, winkel_r)
pwm_l.duty_ns(pos_l)
pwm_r.duty_ns(pos_r)
while True:
  # Linke Seite
  if button_l_minus.value() == 0: # check if button was pressed
      if pos_l >= (deg000 + step): # check if full step possible
       pwm_l.duty_ns(pos_l - step) # doing the step
       pos_l = pos_l - step # updating position variable
       sleep(0.2)
      else:
        pwm_l.duty_ns(deg000) #allow lowest position, if full step was not possible
        sleep(0.2)
  if button_l_plus.value() == 0:
      if pos_l <= (deg090 - step):
       pwm_l.duty_ns(pos_l + step)
       pos_l = pos_l + step
       sleep(0.2)
      else:
        pwm_l.duty_ns(deg090) #allow max position, hier 90°
        sleep(0.2) 
  # Rechte Seite
  if button_r_plus.value() == 0: # check if button was pressed
      if pos_r >= (deg090 + step): # check if full step possible
       pwm_r.duty_ns(pos_r - step) # doing the step
       pos_r = pos_r - step # updating position variable
       sleep(0.2)
      else:
        pwm_r.duty_ns(deg090) #allow 90° Position
        sleep(0.2)
  if button_r_minus.value() == 0:
      if pos_r <= (deg090 - step):
       pwm_r.duty_ns(pos_r + step)
       pos_r = pos_r + step
       sleep(0.2)
      else:
        pwm_r.duty_ns(deg180) #allow rechts 0°
        sleep(0.2) 
LEFT -
LEFT +
RIGHT+
RIGHT-