chore: initialize repository and staged implementation plan
This commit is contained in:
commit
cb0e9d156f
48 files changed
+7343
No files matched your search
@@ -0,0 +1,30 @@
|
||||
import RPi.GPIO as GPIO
|
||||
|
||||
class GateController:
|
||||
def __init__(self, motor_pin1=5, motor_pin2=6, hallA0=22, hallA1=23):
|
||||
self.mp1 = motor_pin1
|
||||
self.mp2 = motor_pin2
|
||||
self.hallA0 = hallA0
|
||||
self.hallA1 = hallA1
|
||||
GPIO.setup(self.mp1, GPIO.OUT)
|
||||
GPIO.setup(self.mp2, GPIO.OUT)
|
||||
GPIO.setup(self.hallA0, GPIO.IN, pull_up_down=GPIO.PUD_UP) # A3144: LOW = магнит
|
||||
GPIO.setup(self.hallA1, GPIO.IN, pull_up_down=GPIO.PUD_UP)
|
||||
self.stop()
|
||||
|
||||
def move(self, direction):
|
||||
if direction == 1:
|
||||
GPIO.output(self.mp1, GPIO.HIGH)
|
||||
GPIO.output(self.mp2, GPIO.LOW)
|
||||
elif direction == -1:
|
||||
GPIO.output(self.mp1, GPIO.LOW)
|
||||
GPIO.output(self.mp2, GPIO.HIGH)
|
||||
else:
|
||||
self.stop()
|
||||
|
||||
def stop(self):
|
||||
GPIO.output(self.mp1, GPIO.LOW)
|
||||
GPIO.output(self.mp2, GPIO.LOW)
|
||||
|
||||
def read_hall_sensors(self):
|
||||
return GPIO.input(self.hallA0), GPIO.input(self.hallA1)
|
||||
Reference in new issue
Block a user