We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
2 parents 91e8339 + 8374e01 commit a1ccd7eCopy full SHA for a1ccd7e
motorized-turntable/turntable.py
@@ -0,0 +1,28 @@
1
+import board
2
+import time
3
+import pulseio
4
+from digitalio import DigitalInOut, Direction, Pull
5
+from analogio import AnalogIn
6
+import adafruit_motor.servo
7
+
8
+pwm = pulseio.PWMOut(board.D5, frequency=50)
9
+servo = adafruit_motor.servo.Servo(pwm)
10
+switch = DigitalInOut(board.D7)
11
+switch.direction = Direction.INPUT
12
+switch.pull = Pull.UP
13
+pot = AnalogIn(board.A0)
14
15
+continuous = adafruit_motor.servo.ContinuousServo(pwm)
16
17
+def val(pin):
18
+ # divides voltage (65535) to get a value between 0 and 1
19
+ return pin.value / 65535
20
21
+while True:
22
23
+ if switch.value:
24
+ continuous.throttle = val(pot) * -1
25
+ else:
26
+ continuous.throttle = val(pot) * 1
27
28
+ time.sleep(0.001)
0 commit comments