from machine import Pin,PWM
from time import sleep
import math
from servo import Servo
from encoder import Encoder
import encoder
led_pin = PWM(Pin(14),freq=2)
#0.1 from 0.5
led_pin.duty(int((20/100)*(2**10-1)))
def handle_encoder_rotation(direction):
if direction == Encoder.ROT_CW:
my_servo1.rotate(9)
my_servo2.rotate(-9)
else:
my_servo1.rotate(-9)
my_servo2.rotate(9)
#frequency = 50 , time = 1/50 = 2*10-3 seconds --> 20ms
my_servo1 = Servo(15)
my_servo2 =Servo(16)
my_encoder = Encoder(25,26,handle_encoder_rotation)
my_servo1.configure(0,180,0.55,2.55)
print("Hello, ESP32!")
while True:
pass