Created
February 2, 2021 09:33
-
-
Save CodeNextPaco/bd0d1d886e58fc9b2aca7fce4bcc1d6e to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from gpiozero import Servo, AngularServo | |
from time import sleep | |
#servo = Servo(21) | |
servo = AngularServo(21, min_angle=0, max_angle=180, min_pulse_width=0.0006, max_pulse_width=0.0024) | |
while True: | |
""" | |
num = input("Enter a number between -1 and 1") | |
num = float(num) | |
if num <= 1 and num >= -1: | |
servo.value = num | |
sleep(1) | |
else: | |
print("That's not allowed") | |
""" | |
v = input("enter a number between 0 and 180 \n") | |
v = float(v) | |
print(type(v)) | |
print(servo.angle) | |
if v<=180 and v >= 0: | |
servo.angle = v | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment