-
Notifications
You must be signed in to change notification settings - Fork 13
/
oeGPIO.py
48 lines (38 loc) · 1.09 KB
/
oeGPIO.py
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
36
37
38
39
40
41
42
43
44
45
46
47
48
#!/usr/bin/python
# Filename : oeGPIO.py
#-----------------------------------
## simple 3d scanner
##----------------------------------
import time
from time import sleep
import RPi.GPIO as GPIO # for step motor
EN2 = 22
DIR2 = 27
STEP2 = 17
dStep=0.00001
#---------------------------------
def oeSetupGPIO():
global EN2,DIR2,STEP2
GPIO.setwarnings(False)
GPIO.setmode(GPIO.BCM)
#GPIO.setup(END2, GPIO.IN, pull_up_down = GPIO.PUD_DOWN)
GPIO.setup(EN2, GPIO.OUT)
GPIO.setup(DIR2, GPIO.OUT)
GPIO.setup(STEP2, GPIO.OUT)
#---------------------------------
def oeMotCCWs(steps,speed):
global EN2,DIR2,STEP2, dStep
#step motor - count clock wise
nas=2 #1600/ot #8=400 #16=200 for 360
GPIO.output(EN2, False)
GPIO.output(DIR2, False)
for tx in range(steps*nas):
time.sleep(dStep*speed)
GPIO.output(STEP2, True)
time.sleep(dStep*speed)
GPIO.output(STEP2, False)
GPIO.output(EN2, True) #aret.
#---------------------------------
def oeMotOff():
GPIO.output(EN2, True) #motor switch off
#---end---