Пример #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
from GPIOLibrary import GPIOProcessor
import time

GP = GPIOProcessor()

try:
    Pin23 = GP.getPin23()
    Pin23.out()

    Pin25 = GP.getPin25()
    Pin25.out()

    Pin27 = GP.getPin27()
    Pin27.out()

    Pin31 = GP.getPin31()
    Pin31.out()

    print("Pins are set to output")

    for i in range(0, 20):
        if Pin23.getValue() == 1:
            Pin23.low()
            Pin25.high()
        elif Pin25.getValue() == 1:
            Pin25.low()
            Pin27.high()
        elif Pin27.getValue() == 1:
            Pin27.low()
            Pin31.high()
        elif Pin31.getValue() == 1:
Пример #3
0
GP = GPIOProcessor()

# GPIO assignment
# TRIG      Pin 23
# ECHO      Pin 27
# GREEN     Pin 24
# YELLOW    Pin 25
# RED       Pin 26

try:

    # Create GPIO variables
    trig = GP.getPin34()
    echo = GP.getPin27()
    green = GP.getPin24()
    yellow = GP.getPin25()
    red = GP.getPin26()

    trig.out()
    echo.input()
    green.out()
    yellow.out()
    red.out()

    # Duration of Activation (seconds)
    D = 10

    # Approximate Speed of Sound (cm/s)
    speed = 34029

    print "Begin"
Пример #4
0
    MAGIC = "face600d"

    server_socket = socket.socket()
    server_host = '192.168.43.20'
    server_port = 5002
    server_socket.bind((server_host, server_port))
    server_socket.listen(5)
    c,addr = server_socket.accept()


    try:
        # Stepper Motor Controls
        A1 = GP.getPin23()    # blue
        A2 = GP.getPin24()    # pink
        B1 = GP.getPin25()    # yellow
        B2 = GP.getPin26()    # orange

        A1.out()
        A2.out()
        B1.out()
        B2.out()

        # Delay time 
        T = 0.001

        # Stepper Sequence (Forward ; Reverse)
        SS = [[[1,1,0,0],[0,1,1,0],[0,0,1,1],[1,0,0,1]],
             [[1,0,0,1],[0,0,1,1],[0,1,1,0],[1,1,0,0]]]

        # Step Angle
GP = GPIOProcessor()

# GPIO assignment
# TRIG      Pin 23
# ECHO      Pin 27
# GREEN     Pin 24
# YELLOW    Pin 25
# RED       Pin 26

try:
    
    # Create GPIO variables
    trig    = GP.getPin34()
    echo    = GP.getPin27()
    green   = GP.getPin24()
    yellow  = GP.getPin25()
    red     = GP.getPin26()

    trig.out()
    echo.input()
    green.out()
    yellow.out()
    red.out()

    # Duration of Activation (seconds)
    D = 10 

    # Approximate Speed of Sound (cm/s)
    speed = 34029

    print "Begin"