Пример #1
0
class GPIO():
    def __init__(self):
        pass

    def __enter__(self):
        self.GP = GPIOProcessor()
        self.forward_pin = self.GP.getPin25()
        self.forward_pin.out()
        self.right_high = self.GP.getPin26()
        self.right_high.out()
        self.right_low = self.GP.getPin27()
        self.right_low.out()
        self.left_high = self.GP.getPin29()
        self.left_high.out()
        self.left_low = self.GP.getPin30()
        self.left_low.out()
        return self

    def __exit__(self, exc_type, exc_val, exc_tb):
        self.GP.cleanup()

    def brake(self):
        self.forward_pin.low()

    def unbrake(self):
        self.forward_pin.high()

    def turn_left(self):
        self.left_low.low()
        self.left_high.high()

    def turn_right(self):
        self.right_low.low()
        self.right_high.high()
Пример #2
0
# Stepper motor switching sequence
seq = [[1, 0, 0, 0], [1, 1, 0, 0], [0, 1, 0, 0], [0, 1, 1, 0], [0, 0, 1, 0],
       [0, 0, 1, 1], [0, 0, 0, 1], [1, 0, 0, 1]]

stepAngle = 5.625
delay = 0.0003
#delay = 1

GP = GPIOProcessor()

try:
    # Use pins 231, 33, 30, and 34 to control motor
    out0 = GP.getPin29()  # Blue
    out1 = GP.getPin33()  # Pink
    out2 = GP.getPin30()  # Yellow
    out3 = GP.getPin34()  # Orange

    outl = [out0, out1, out2, out3]
    outl.reverse()

    # Set the pin direction to out
    for k in range(4):
        outl[k].out()

    # Rotation in degrees
    degrees = 90
    steps_per_deg = 4076.0 / 360.0
    steps = math.floor(steps_per_deg * degrees)

    for k in range(steps):
Пример #3
0
from GPIOLibrary import GPIOProcessor
import time
import numpy as np
GP = GPIOProcessor()

try:
    trig = GP.getPin29()
    trig.out()

    echo = GP.getPin30()
    echo.input()

    trig.low()
    print("Wait for sensor to settle")
    time.sleep(2)
    distances = []
    for i in range(15):
        pulseStart = 0
        pulseEnd = 0
        isOutR = False
        init = time.clock()
        trig.high()
        time.sleep(0.00001)
        trig.low()
        while (echo.getValue() == 0):
            pulseStart = time.clock()
            if (pulseStart - init > 0.3):
                print("out of range")
                isOutR = True
                break
        pulseEnd = time.clock()
Пример #4
0
#Ind    = 30

Din = GP.getPin27()
Din.input()
A1 = GP.getPin34()
A1.out()
A2 = GP.getPin33()
A2.out()
A3 = GP.getPin24()
A3.out()
A4 = GP.getPin26()
A4.out()
PIR = GP.getPin29()
PIR.out()
PIR.low()
Ind = GP.getPin30()
Ind.out()
Ind.low()

# Remote Average Pulse
M = 800

# Stepper Motor Delay
t = 0.001

# Stepper Motor Sequence (Forward / Reverse)
A = [[[0,1,0,1],[1,0,0,1],[1,0,1,0],[0,1,1,0]],
     [[0,1,0,1],[0,1,1,0],[1,0,1,0],[1,0,0,1]]]

# Indicators
FR = 0
Пример #5
0
# Stepper motor switching sequence
seq = [[1,0,0,0], [1,1,0,0], [0,1,0,0], [0,1,1,0],
       [0,0,1,0], [0,0,1,1], [0,0,0,1], [1,0,0,1]]

stepAngle = 5.625
delay = 0.0003
#delay = 1

GP = GPIOProcessor()

try:
    # Use pins 231, 33, 30, and 34 to control motor
    out0 = GP.getPin29()  # Blue
    out1 = GP.getPin33()  # Pink
    out2 = GP.getPin30()  # Yellow
    out3 = GP.getPin34()  # Orange

    outl = [out0, out1, out2, out3]
    outl.reverse()

    # Set the pin direction to out
    for k in range(4):
        outl[k].out()

    # Rotation in degrees
    degrees = 90
    steps_per_deg =4076.0/360.0
    steps = math.floor(steps_per_deg * degrees)

    for k in range(steps):
Пример #6
0
#Ind    = 30

Din = GP.getPin27()
Din.input()
A1 = GP.getPin34()
A1.out()
A2 = GP.getPin33()
A2.out()
A3 = GP.getPin24()
A3.out()
A4 = GP.getPin26()
A4.out()
PIR = GP.getPin29()
PIR.out()
PIR.low()
Ind = GP.getPin30()
Ind.out()
Ind.low()

# Remote Average Pulse
M = 800

# Stepper Motor Delay
t = 0.001

# Stepper Motor Sequence (Forward / Reverse)
A = [[[0, 1, 0, 1], [1, 0, 0, 1], [1, 0, 1, 0], [0, 1, 1, 0]],
     [[0, 1, 0, 1], [0, 1, 1, 0], [1, 0, 1, 0], [1, 0, 0, 1]]]

# Indicators
FR = 0