a
This commit is contained in:
File diff suppressed because one or more lines are too long
35
manualControl.py
Normal file
35
manualControl.py
Normal file
@@ -0,0 +1,35 @@
|
||||
import time
|
||||
from adafruit_servokit import ServoKit
|
||||
|
||||
# Initialize ServoKit
|
||||
kit = ServoKit(channels=16)
|
||||
|
||||
# Constants for delay
|
||||
DELAY = 1
|
||||
|
||||
# Function to move a specified leg to a specified angle
|
||||
def move_leg(leg, angle):
|
||||
print(f"Moving leg {leg} to angle {angle}.")
|
||||
kit.servo[leg].angle = angle
|
||||
time.sleep(DELAY)
|
||||
|
||||
# Main function
|
||||
def main():
|
||||
while True:
|
||||
try:
|
||||
leg = int(input("Enter the leg number (0-15): "))
|
||||
if leg < 0 or leg > 15:
|
||||
print("Invalid leg number. Please enter a number between 0 and 15.")
|
||||
continue
|
||||
|
||||
angle = int(input("Enter the angle (0-180): "))
|
||||
if angle < 0 or angle > 180:
|
||||
print("Invalid angle. Please enter a number between 0 and 180.")
|
||||
continue
|
||||
|
||||
move_leg(leg, angle)
|
||||
except ValueError:
|
||||
print("Invalid input. Please enter numeric values.")
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
Reference in New Issue
Block a user