Example #1
0
	def __init__(self, pwm0, pwm1, pwm2, pwm3):
		"""
		"""
		self.mux = MCP230XX(0x20, 16, 1)

		for pin in range(0, 15):
			self.mux.config(pin, OUT)

		# this can be:
		# BOARD -> Board numbering scheme. The pin numbers follow the pin numbers on header P1.
		# BCM -> Broadcom chip-specific pin numbers.
# 		GPIO.setmode(GPIO.BCM)
		setmode(BCM)  # Pi cover uses BCM pin numbers, GPIO.BCM = 11
		setup([pwm0, pwm1, pwm2, pwm3], OUT)  # GPIO.OUT = 0

		freq = 100.0  # Hz
		self.motor0 = PWM(pwm0, freq)
		self.motor1 = PWM(pwm1, freq)
		self.motor2 = PWM(pwm2, freq)
		self.motor3 = PWM(pwm3, freq)

		self.motor0.start(0)
		self.motor1.start(0)
		self.motor2.start(0)
		self.motor3.start(0)
def setup_sensor():
    '''Setup the environment
    mode BCM
    using TRIGGER as output
    using ECHO    as input
    '''
    setmode(BCM)
    setup(PIN_TRIGGER, OUT)
    setup(PIN_ECHO, IN)
Example #3
0
def setup_gpio():
    setmode(BCM)
    setwarnings(False)

    for led in LEDS:
        setup(led, OUT)

    setup(BUTTON, IN, pull_up_down=PUD_UP)
    cleanup()
Example #4
0
def setup_env() :
    '''set up the PINs
    
    Disabble warnings in case of pins already 
        in use due to another program before
    '''
    setwarnings (False)
    
    setmode (BCM)
    setup (PIN_LED,     OUT)
    setup (PIN_TRIGGER, OUT)
    setup (PIN_ECHO,    IN )
Example #5
0
def setup_gpio():

    setmode(BCM)
    setwarnings(False)

    for led in TOP_ROW + MIDDLE_ROW + BOTTOM_ROW:
        setup(led, OUT)

    setup(TOP_ADD_BUTTON, IN, pull_up_down=PUD_UP)
    setup(TOP_SUB_BUTTON, IN, pull_up_down=PUD_UP)
    setup(BOT_ADD_BUTTON, IN, pull_up_down=PUD_UP)
    setup(BOT_SUB_BUTTON, IN, pull_up_down=PUD_UP)
    cleanup()
Example #6
0
    def __init__(self, gpio, active=True, direction="OUT", state="LOW"):
        directions = {"IN": IN, "OUT": OUT}
        states = {"LOW": self.low, "HIGH": self.high}

        assert isinstance(gpio, int), gpio
        assert isinstance(active, bool), active
        assert direction in directions, direction
        assert state in states, state

        self.gpio = gpio
        self.active = active

        setwarnings(False)
        setmode(BCM)
        setup(self.gpio, directions[direction])

        states[state]()
Example #7
0
def setup_gpio():

    setmode(BCM)
    setwarnings(False)

    for led in BIT_LEDS + [ONE_HUNDRED_LED, TWO_HUNDRED_LED]:
        setup(led, OUT)

    for segment in LSD + MSD:
        setup(segment, OUT)

    setup(BEEPER, OUT)
    setup(BUTTON, IN, pull_up_down=PUD_UP)

    cleanup()

    for segment in [0, 1, 2, 3, 4, 5]:
        output(LSD[segment], HIGH)
        output(MSD[segment], HIGH)
Example #8
0
from RPi.GPIO import setmode, setwarnings, setup, output, BCM, HIGH, LOW, OUT, cleanup
from time import sleep

pins = [17, 27, 22, 23]

setmode(BCM)
setwarnings(False)

for i in pins:
    setup(i, OUT)
    output(i, 0)

c = [
    [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]
]

for i in range(512):
    for i in range(8):

        for j in range(4):
            output(pins[j], c[i][j])

        sleep(0.01)
from RPi.GPIO import setup, OUT, PWM, output, LOW, HIGH, cleanup, setmode, BCM
from wsgiref.simple_server import make_server
from pyramid.config import Configurator
from pyramid.response import Response

__author__ = 'root'

setmode(BCM)

setup(17, OUT)
setup(20, OUT)
setup(22, OUT)
setup(5, OUT)
setup(6, OUT)
setup(13, OUT)

isForward = None
isBackward = None

def default_response():
    return Response('<font size=400><center>'
                    '<a href=/move/f>forward</a><br><br>'
                    '<a href=/move/l>left</a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'
                    '<a href=/move/s>stop</a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'
                    '<a href=/move/r>right</a><br><br>'
                    '<a href=/move/b>backward</a></center></font>')

def right(duty=100):
    output(5, HIGH)
    output(6, LOW)
    p2.ChangeDutyCycle(float(duty))
Example #10
0
	def __init__(self):
		setmode(BCM)
		setup(STATUS_GPIO_PIN, OUT, initial=LOW)
Example #11
0
from .DCMoteur import DCMoteur, GroupeDCMoteur
from .Servomoteur import Servomoteur
from .AbstractMoteur import AbstractMoteur
from config import get as conf
from RPi.GPIO import setmode, setwarnings, BOARD

setmode(BOARD)
setwarnings(False)
AbstractMoteur.pwm.set_pwm_freq(conf("controle.pwm_frequence"))


moteur1 = DCMoteur(conf("controle.moteur.gauche.channel"),
                   *conf("controle.moteur.gauche.pins"))

moteur2 = DCMoteur(conf("controle.moteur.droit.channel"),
                   *conf("controle.moteur.droit.pins"))

servo_x = Servomoteur(conf("controle.servo.camera.X.initial"),
                      conf("controle.servo.camera.X.correction"),
                      conf("controle.servo.camera.X.min"),
                      conf("controle.servo.camera.X.max"),
                      conf("controle.servo.camera.X.channel"))

servo_y = Servomoteur(conf("controle.servo.camera.Y.initial"),
                      conf("controle.servo.camera.Y.correction"),
                      conf("controle.servo.camera.Y.min"),
                      conf("controle.servo.camera.Y.max"),
                      conf("controle.servo.camera.Y.channel"))

servo_dir = Servomoteur(conf("controle.servo.direction.initial"),
                        conf("controle.servo.direction.correction"),
Example #12
0
 def __init__(self):
     setmode(BCM)
     setup(ELEMENT_GPIO_PIN, OUT, initial=LOW)
Example #13
0
 def __init__(self):
     """Initialise GPIO pins."""
     setmode(BOARD)
     setup(ULN2003.OUTPUT_PINS, OUT, initial=LOW)
Example #14
0
from RPi.GPIO import cleanup, setmode, setup, output, BOARD, OUT
from time import sleep

setmode(BOARD)
setup(7, OUT)

def on():
    output(7, True)
def off():
    output(7, False)
def blink(n=5, s=.5):
    for i in range(n):
        on()
        sleep(s)
        off()
        sleep(s)

To_Morse = dict({"A": ".-", "B": "-...", "C": "-.-.", "D": "-..", "E": ".", "F": "..-.", "G": "--.", "H": "....", "I": "..", "J": ".---", "K": "-.-", "L": ".-..", "M": "--", "N": "-.", "O": "---", "P": ".--.", "Q": "--.-", "R": ".-.", "S": "...", "T": "-", "U": "..-", "V": "...-", "W": ".--", "X": "-..-", "Y": "-.--", "Z": "--..", "1": ".----", "2": "..---", "3": "...--", "4": "....-", "5": "-....", "6": "--...", "7": "---..", "8": "----.", "9": "----.", "0": "-----"})

def getMorse(inputText):
    nuString = ""
    for i in inputText:
        if i == " ":
            nuString = nuString + To_Morse[i.upper()] + "|"
        else:
            nuString = nuString + " "
    return nuString


def parseOneZero(string):
    pass
 def __init_rasp_config (self) :
     setmode (BCM)
     setup   (PIN_SIG, OUT)
     output  (PIN_SIG, LOW)