-
-
Save CodeNextAdmin/18aaf4bc3740ae3b17291bfd3be458ac 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