From f75fb0a1989f7cc55406fe742763360d89f968d3 Mon Sep 17 00:00:00 2001 From: tpollina Date: Tue, 10 Dec 2019 12:06:56 -0800 Subject: [PATCH] Create Focus_actuation.py --- Focus_actuation.py | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 Focus_actuation.py diff --git a/Focus_actuation.py b/Focus_actuation.py new file mode 100644 index 0000000..f96c6b9 --- /dev/null +++ b/Focus_actuation.py @@ -0,0 +1,27 @@ +from adafruit_motor import stepper +from adafruit_motorkit import MotorKit +from time import sleep +kit = MotorKit() + +stage = kit.stepper1 + +stage.release() + +def focus_actuation(steps,orientation): + + stage.release() + + if orientation == 'FORWARD': + for i in range(steps): + stage.onestep(direction=stepper.FORWARD, style=stepper.MICROSTEP) + sleep(0.001) + + if orientation == 'BACKWARD': + for i in range(steps): + stage.onestep(direction=stepper.BACKWARD, style=stepper.MICROSTEP) + sleep(0.001) + + stage.release() + +focus_actuation(1000,'FORWARD') +focus_actuation(1000,'BACKWARD')