From 8dcbaded2d230155c2c8f72dcfcb35a5868b6508 Mon Sep 17 00:00:00 2001 From: KenwoodFox Date: Mon, 21 Jun 2021 13:21:32 -0400 Subject: [PATCH] Add servo example, servo action is jerky but functional --- crawler_software/servo_test.py | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 crawler_software/servo_test.py diff --git a/crawler_software/servo_test.py b/crawler_software/servo_test.py new file mode 100644 index 0000000..836b70c --- /dev/null +++ b/crawler_software/servo_test.py @@ -0,0 +1,19 @@ +import RPi.GPIO as GPIO +import time + +servoPIN = 17 +GPIO.setmode(GPIO.BCM) +GPIO.setup(servoPIN, GPIO.OUT) + +p = GPIO.PWM(servoPIN, 50) # GPIO 17 for PWM with 50Hz +p.start(2.5) # Initialization +try: + while True: + p.ChangeDutyCycle(10) + time.sleep(2) + p.ChangeDutyCycle(2.5) + time.sleep(2) +except KeyboardInterrupt: + p.stop() + GPIO.cleanup() +