예제 #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
]

try:
    steps_made = 0

    pins = [
        GP.getPin31(),
        GP.getPin32(),
        GP.getPin33(),
        GP.getPin34(),
    ]

    for p in pins:
        p.out()

    right = GP.getPin27()
    right.input()
    left = GP.getPin26()
    left.input()
    reset = GP.getPin24()
    reset.input()

    sequence = FULL_STEP_SEQUENCE
    i = 0
    direction = 0
    resetting = False

    while True:
        time.sleep(DELAY)

        for p in pins:
예제 #3
0
from GPIOLibrary import GPIOProcessor
import time

GP = GPIOProcessor()

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

    Pin29 = GP.getPin29()
    Pin29.input()	

    for i in range(0,20):
        pinValue = Pin29.getValue();
	
	if pinValue == 1:
	    Pin27.high()
        else:
            Pin27.low()
        time.sleep(1)

finally:
    GP.cleanup()
예제 #4
0
import math

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
import math

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
예제 #6
0
from GPIOLibrary import GPIOProcessor
import time

GP = GPIOProcessor()

# GPIO Assignments
#Din    = 27
#A1     = 34	Green
#A2     = 33	White
#A3     = 24   	Black
#A4     = 26	Yellow
#PIR    = 29
#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()
예제 #7
0
from GPIOLibrary import GPIOProcessor
import time

GP = GPIOProcessor()

# GPIO Assignments
#Din    = 27
#A1     = 34	Green
#A2     = 33	White
#A3     = 24   	Black
#A4     = 26	Yellow
#PIR    = 29
#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()