-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmotor.py
More file actions
34 lines (28 loc) · 784 Bytes
/
motor.py
File metadata and controls
34 lines (28 loc) · 784 Bytes
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
import sys
import time
import RPi.GPIO as GPIO
class motor:
def __init__(self):
self.IsOutside = True
GPIO.setup(26, GPIO.OUT,initial=False)
GPIO.setup(20, GPIO.OUT,initial=False)
self.forward = GPIO.PWM(26, 100)
self.backward = GPIO.PWM(20, 100)
def outside(self):
if self.IsOutside == True:
return
time.sleep(0.5)
self.forward.start(35)
time.sleep(0.5)
self.forward.stop()
time.sleep(0.5)
self.IsOutside = True
def inside(self):
if self.IsOutside == False:
return
time.sleep(0.5)
self.backward.start(35)
time.sleep(0.5)
self.backward.stop()
time.sleep(0.5)
self.IsOutside = False