-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSwitch Triggered
35 lines (23 loc) · 936 Bytes
/
Switch Triggered
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# Auto detect text files and perform LF normalization
#* text=auto
# import the libraries
import RPi.GPIO as GPIO
from time import sleep
GPIO.setmode(GPIO.BCM)
Switch = 26 # Switch Pin
GPIO.setup(Switch, GPIO.IN, pull_up_down=GPIO.PUD_UP) #Switch input pin with pull-up resistor
from RpiMotorLib import RpiMotorLib
#define GPIO pins
GPIO_pins = (25, 8, 7) # Microstep Resolution MS1-MS3 -> GPIO Pin
direction = 24 # Direction Pin,
step = 23 # Step Pin
# Declare an named instance of class pass GPIO pins numbers
mymotortest = RpiMotorLib.A4988Nema(direction, step, GPIO_pins, "A4988")
while True:
if GPIO.input (Switch) == 0:
mymotortest.motor_go(False, "Full" , 100, .01, False, .05)
sleep(0.2)
else:
mymotortest.motor_go(True, "Full" , 100, .01, False, .05)
sleep(0.2)
GPIO.cleanup()