Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #importar librerias
- from machine import Pin, PWM
- from time import sleep
- #codigo de programa
- def main():
- #configuracion de pulso de servo
- pin_servo = Pin(25)
- pul_servo = PWM(pin_servo)
- pul_servo.freq(50)
- #variables de incremento y de duty inicial
- step = 2
- duty = 18
- #ciclo infinito de programa
- while(1):
- #evaluar limites para 0° y 180°
- if(duty<18):
- step = 2
- elif(duty>115):#sirve para enlazar varias condiciones
- step = -2
- #incrementar duty y fijar
- duty = duty + step
- pul_servo.duty(duty)
- #tiempo entre variacion
- sleep(0.2)
- print(pul_servo.duty())
- if __name__ == "__main__":
- main()
Add Comment
Please, Sign In to add comment