Beispiel #1
0
 def __init__(self, r_pin, g_pin, b_pin):
     self.r_pin = r_pin
     self.b_pin = b_pin
     self.g_pin = g_pin
     self.r_pwm = wiringpi.softPwmCreate(r_pin, 0, 100)
     self.g_pwm = wiringpi.softPwmCreate(g_pin, 0, 100)
     self.b_pwm = wiringpi.softPwmCreate(b_pin, 0, 100)
     self.red = 0
     self.green = 0
     self.blue = 0
     self.set(0,0,0)
Beispiel #2
0
def big_test_a_bunch_of_ranges():
    def testrange(top):
        for i in range(0, top, int(top/10)):
            print('sending {}'.format(i))
            wiringpi.softPwmWrite(servo_gpio_pin, i)
            time.sleep(1)


    for k in range(10, 1000, 50):
        time.sleep(2)
        print('creating pin', k)
        wiringpi.softPwmCreate(17, 0, k)
        testrange(k)
Beispiel #3
0
    def gpio_init(self):
        
        wp.wiringPiSetupSys()

        # Set output for those pins :
        wp.pinMode(self.pin_power_left, wp.OUTPUT)
        wp.pinMode(self.pin_power_right, wp.OUTPUT)
        wp.pinMode(self.pin_direction_left_forward, wp.OUTPUT)
        wp.pinMode(self.pin_direction_right_forward, wp.OUTPUT)
        wp.pinMode(self.pin_direction_left_rear, wp.OUTPUT)
        wp.pinMode(self.pin_direction_right_rear, wp.OUTPUT)
        
        ## create the SoftPwm on power pins :     
        wp.softPwmCreate(self.pin_power_left, 0, self.max_speed)
        wp.softPwmCreate(self.pin_power_right, 0, self.max_speed)

        ## reset everyone :
        self.gpio_zero()
def setup_gpio():
    wiringpi.wiringPiSetupGpio()

    wiringpi.pinMode(LEFT_FORWARD, 1)
    wiringpi.pinMode(LEFT_BACKWARD, 1)
    wiringpi.pinMode(RIGHT_FORWARD, 1)
    wiringpi.pinMode(RIGHT_BACKWARD, 1)

    wiringpi.softPwmCreate(LEFT_FORWARD, 0, 100)
    wiringpi.softPwmCreate(LEFT_BACKWARD, 0, 100)
    wiringpi.softPwmCreate(RIGHT_FORWARD, 0, 100)
    wiringpi.softPwmCreate(RIGHT_BACKWARD, 0, 100)
Beispiel #5
0
    def initialize_state(self):
        self._not_initialized = False
        self._MAX_SPEED = self.config.get('max_motor_speed', 10)
        self._MIN_SPEED = self._MAX_SPEED * -1
        self.MIN_SERVO = self.config.get('min_servo', 100)
        self.MAX_SERVO = self.config.get('max_servo', 100)
        self.ZERO_SERVO = self.config.get('zero-servo', 150)
        self._INITIAL_SERVO = 100
        gears = 5
        for index in range(1, gears + 1):
            self.gear_lookup[index] = int((self._MAX_SPEED / gears) * index)
        logger.info('Setting gears: ' + str(self.gear_lookup))

        if self.use_motors or self.use_servo:
            res = wiringpi.wiringPiSetupGpio()
            if res != 0:
                logger.error('Could not set up software PWM')
        if self.use_motors:
            logger.info('Setting up Motor Software-Based PWM')
            # a cluster of horrible looking code, should be refactored but is it single use???
            wiringpi.pinMode(self.m1conf.get('en_pin'), wiringpi.GPIO.OUTPUT)
            wiringpi.pinMode(self.m1conf.get('dir_pin'), wiringpi.GPIO.OUTPUT)
            wiringpi.pinMode(self.m2conf.get('en_pin'), wiringpi.GPIO.OUTPUT)
            wiringpi.pinMode(self.m2conf.get('dir_pin'), wiringpi.GPIO.OUTPUT)
            logger.info('Pull both motors out of low-power mode')
            wiringpi.digitalWrite(self.m1conf.get('en_pin'), 1)
            wiringpi.digitalWrite(self.m2conf.get('en_pin'), 1)
            logger.info('Set up motor software pwm')
            wiringpi.softPwmCreate(self.m1conf.get('pwm_pin'), 0, self._MAX_SPEED)
            wiringpi.softPwmCreate(self.m2conf.get('pwm_pin'), 0, self._MAX_SPEED)
            wiringpi.softPwmWrite(self.m1conf.get('pwm_pin'), 0)
            wiringpi.softPwmWrite(self.m2conf.get('pwm_pin'), 0)
            logger.info('Setting motor speeds to zero.')
        if self.use_servo:
            logger.info('Setting up Servo Hardware-Based PWM')
            wiringpi.pinMode(self.servo_gpio_pin, wiringpi.GPIO.PWM_OUTPUT)
            wiringpi.pwmSetMode(wiringpi.GPIO.PWM_MODE_MS)
            wiringpi.pwmSetClock(192)
            wiringpi.pwmSetRange(2000)
            logger.info('Servo config done')
            wiringpi.pwmWrite(self.servo_gpio_pin, self.ZERO_SERVO)
            logger.info('Setting servo speed to zero.')
Beispiel #6
0
def setup_and_test(pin, small, large, first):
    print('{} {} {}'.format(small, large, first))

    print('creating pin')
    cr = wiringpi.softPwmCreate(pin, small, large)
    print('Create results: {}'.format(cr))

    print('first write')
    wres = wiringpi.softPwmWrite(servo_gpio_pin, first)
    print('Write res {}'.format(wres))

    time.sleep(1)
    print('done sleeping')
    wiringpi.softPwmWrite(servo_gpio_pin, small)
def main():
    context = zmq.Context()
    socket = context.socket(zmq.SUB)
    socket.setsockopt(zmq.SUBSCRIBE, '')
    socket.connect('tcp://192.168.2.1:7777')

    wiringpi.wiringPiSetup()
    wiringpi.softPwmCreate(RED_PIN, 0, 255)
    wiringpi.softPwmCreate(GREEN_PIN, 0, 255)
    wiringpi.softPwmCreate(BLUE_PIN, 0, 255)

    while True:
        rgb = int(socket.recv())
        red = (rgb >> 16) & 0xFF
        green = (rgb >> 8) & 0xFF
        blue = rgb & 0xFF

        wiringpi.softPwmWrite(RED_PIN, red)
        wiringpi.softPwmWrite(GREEN_PIN, green)
        wiringpi.softPwmWrite(BLUE_PIN, blue)
Beispiel #8
0
 def __init__(self, pin):
     self.pin = pin
     self.forwards_pulse = 10
     self.backwards_pulse = 30
     gpio.softPwmCreate(pin, 50, 100)
     gpio.softPwmWrite(self.pin, 0)
Beispiel #9
0
import wiringpi as pi
import time

LED_PIN = 23

pi.wiringPiSetupGpio()
pi.pinMode(LED_PIN, pi.OUTPUT)

pi.softPwmCreate(LED_PIN, 0, 100)
pi.softPwmWrite(LED_PIN, 50)

time.sleep(100)
Beispiel #10
0
import wiringpi
import time
import os

pin = 0
wiringpi.wiringPiSetup()

# wiringpi.wiringPiSetupSys()
# os.system('gpio export 17 out')

wiringpi.digitalWrite(pin, 1)
time.sleep(0.5)
wiringpi.digitalWrite(pin, 0)
time.sleep(0.5)
wiringpi.digitalWrite(pin, 1)
time.sleep(0.5)
wiringpi.digitalWrite(pin, 0)
time.sleep(0.5)

pin = wiringpi.softPwmCreate(pin, 0, 100)

while True:
    for value in range(0, 100):
        wiringpi.softPwmWrite(pin, value)
        print value
        time.sleep(0.01)
    for value in range(100, 0, -1):
        wiringpi.softPwmWrite(pin, value)
        print value
        time.sleep(0.01)
Beispiel #11
0
except redis.ConnectionError:
    print "Error: cannot connect to redis server"
    exit()

# wiringpi.wiringPiSetup()
wiringpi.wiringPiSetupGpio()

pinR = config.getint('output', 'red')
pinG = config.getint('output', 'green')
pinB = config.getint('output', 'blue')

wiringpi.pinMode(pinR, wiringpi.OUTPUT)
wiringpi.pinMode(pinG, wiringpi.OUTPUT)
wiringpi.pinMode(pinB, wiringpi.OUTPUT)

wiringpi.softPwmCreate(pinR, 0, 127)
wiringpi.softPwmCreate(pinG, 0, 127)
wiringpi.softPwmCreate(pinB, 0, 127)

while True:
    time.sleep(config.getfloat('general', 'delay'))

    valR = EEGsynth.getint('input', 'red',   config, r) * EEGsynth.getfloat('scaling', 'red',   config, r)
    valG = EEGsynth.getint('input', 'green', config, r) * EEGsynth.getfloat('scaling', 'green', config, r)
    valB = EEGsynth.getint('input', 'blue',  config, r) * EEGsynth.getfloat('scaling', 'blue',  config, r)

    print valR, valG, valB

    wiringpi.softPwmWrite(pinR, int(valR))
    wiringpi.softPwmWrite(pinG, int(valG))
    wiringpi.softPwmWrite(pinB, int(valB))
Beispiel #12
0
# -*- coding: utf-8 -*-
import time
import wiringpi as pi

motor1_pin = 23
motor2_pin = 24
SW_PIN = 4
SW2_PIN = 10

pi.wiringPiSetupGpio()
pi.pinMode(SW_PIN, pi.INPUT)
pi.pinMode(motor1_pin, pi.OUTPUT)
pi.pinMode(motor2_pin, pi.OUTPUT)

pi.softPwmCreate(motor1_pin, 0, 100)
pi.softPwmCreate(motor2_pin, 0, 100)

pi.softPwmWrite(motor1_pin, 0)
pi.softPwmWrite(motor2_pin, 0)

max_speed = 30
max2_speed = max_speed - 1


def go_up():

    print("go_start")
    pi.softPwmWrite(motor1_pin, 0)
    pi.softPwmWrite(motor2_pin, 0)
    time.sleep(1)
Beispiel #13
0
import wiringpi as pi
import time

green_pin = 18
blue_pin = 23
red_pin = 24

pi.wiringPiSetupGpio()
pi.pinMode(green_pin, pi.OUTPUT)
pi.pinMode(blue_pin, pi.OUTPUT)
pi.pinMode(red_pin, pi.OUTPUT)

pi.softPwmCreate(green_pin, 0, 100)
pi.softPwmCreate(blue_pin, 0, 100)
pi.softPwmCreate(red_pin, 0, 100)

pi.softPwmWrite(green_pin, 0)
pi.softPwmWrite(blue_pin, 100)
pi.softPwmWrite(red_pin, 100)
Beispiel #14
0
green_back = 21
blue_back = 17

wiringpi.wiringPiSetupGpio() #this comand tells the program to use the GPIO pinout

#these comands set up each pin as outputs
# 1 = output 0 = input
wiringpi.pinMode(red_back, 1)
wiringpi.pinMode(blue_back, 1)
wiringpi.pinMode(green_back, 1)
wiringpi.pinMode(red_front, 1)
wiringpi.pinMode(blue_front, 1)
wiringpi.pinMode(green_front, 1)

#thest comands create the ablity for PWM on each pin with the range of each
wiringpi.softPwmCreate(red_front, OFF, ON)
wiringpi.softPwmCreate(blue_front, OFF, ON)
wiringpi.softPwmCreate(green_front, OFF, ON)
wiringpi.softPwmCreate(red_back, OFF, ON)
wiringpi.softPwmCreate(blue_back, OFF, ON)
wiringpi.softPwmCreate(green_back, OFF, ON)

def resetpins():
    wiringpi.softPwmWrite(red_front, pinArray[0])
    wiringpi.softPwmWrite(blue_front, pinArray[1])
    wiringpi.softPwmWrite(green_front, pinArray[2])
    wiringpi.softPwmWrite(red_back, pinArray[0])
    wiringpi.softPwmWrite(blue_back, pinArray[1])
    wiringpi.softPwmWrite(green_back, pinArray[2])

def setup():
Beispiel #15
0
    def __init__(self, pf, pb):
        self.pinForward = pf
        self.pinBack = pb

        wiringpi.softPwmCreate(pf, 0, 80)
        wiringpi.softPwmCreate(pb, 0, 80)
def Motor(x, y, pwm):
    wp.pinMode(x, 1)
    wp.pinMode(y, 1)
    wp.pinMode(pwm, 1)
    wp.softPwmCreate(pwm, 0, 500)
    return x, y, pwm
import MCP3202, os
from time import sleep
import wiringpi as wpi

MICRO_SERVO = 1

wpi.wiringPiSetup()
wpi.softPwmCreate(MICRO_SERVO, 0, 200)


def translate(value, leftMin, leftMax, rightMin, rightMax):
    # Figure out how 'wide' each range is
    leftSpan = leftMax - leftMin
    rightSpan = rightMax - rightMin
    # Convert the left range into a 0-1 range (float)
    valueScaled = float(value - leftMin) / float(leftSpan)
    # Convert the 0-1 range into a value in the right range.
    return rightMin + (valueScaled * rightSpan)


try:
    while True:
        os.system("clear")
        value1 = MCP3202.readADC(0)
        map = translate(value1, 0, 4095, 6, 24)
        position = translate(value1, 0, 4095, 0, 180)
        print("Servo Position")
        print("Curent Position : ", int(position), "degree")
        print("")
        print("Press CTRL+C to exit")
        wpi.softPwmWrite(MICRO_SERVO, int(map))
Beispiel #18
0
import wiringpi
import time
import os

pin = 0
wiringpi.wiringPiSetup()

# wiringpi.wiringPiSetupSys()
# os.system('gpio export 17 out')

wiringpi.digitalWrite(pin,1)
time.sleep(0.5);
wiringpi.digitalWrite(pin,0)
time.sleep(0.5);
wiringpi.digitalWrite(pin,1)
time.sleep(0.5);
wiringpi.digitalWrite(pin,0)
time.sleep(0.5);

pin = wiringpi.softPwmCreate(pin,0,100)

while True:
    for value in range(0,100):
        wiringpi.softPwmWrite(pin, value)
        print value
        time.sleep(0.01);
    for value in range(100,0,-1):
        wiringpi.softPwmWrite(pin, value)
        print value
        time.sleep(0.01);
Beispiel #19
0
# Pulsates an LED connected to GPIO pin 1 with a suitable resistor 4 times using softPwm
# softPwm uses a fixed frequency
import wiringpi

OUTPUT = 1

PIN_TO_PWM = 1

wiringpi.wiringPiSetup()
wiringpi.pinMode(PIN_TO_PWM,OUTPUT)
wiringpi.softPwmCreate(PIN_TO_PWM,0,100) # Setup PWM using Pin, Initial Value and Range parameters

for time in range(0,4):
	for brightness in range(0,100): # Going from 0 to 100 will give us full off to full on
		wiringpi.softPwmWrite(PIN_TO_PWM,brightness) # Change PWM duty cycle
		wiringpi.delay(10) # Delay for 0.2 seconds
	for brightness in reversed(range(0,100)):
		wiringpi.softPwmWrite(PIN_TO_PWM,brightness)
		wiringpi.delay(10)
import wiringpi
import time

rightMotorDir = 29
leftMotorDir = 28
rightMotorSpeed = 23
leftMotorSpeed = 26

wiringpi.wiringPiSetup()
wiringpi.pinMode(rightMotorDir, 1)
wiringpi.pinMode(leftMotorDir, 1)
wiringpi.pinMode(rightMotorSpeed, 1)
wiringpi.pinMode(leftMotorSpeed, 1)

wiringpi.softPwmCreate(rightMotorSpeed, 0, 100)
wiringpi.softPwmCreate(leftMotorSpeed, 0, 100)

# Start with low power for 3 seconds
wiringpi.digitalWrite(rightMotorDir, 1)
wiringpi.digitalWrite(leftMotorDir, 0)

wiringpi.softPwmWrite(rightMotorSpeed, 100)
wiringpi.softPwmWrite(leftMotorSpeed, 100)

time.sleep(1)

# Switch direction
wiringpi.digitalWrite(rightMotorDir, 0)
wiringpi.digitalWrite(leftMotorDir, 1)

time.sleep(1)
def Motor(a, b, pwm):
    wp.pinMode(a, 1)
    wp.pinMode(b, 1)
    wp.pinMode(pwm, 1)
    wp.softPwmCreate(pwm, 0, 400)
    return a, b, pwm
Beispiel #22
0
def setup():
    wiringpi.wiringPiSetupGpio()

    wiringpi.pinMode(red_back, 1)
    wiringpi.pinMode(blue_back, 1)
    wiringpi.pinMode(green_back, 1)
    wiringpi.pinMode(red_front, 1)
    wiringpi.pinMode(blue_front, 1)
    wiringpi.pinMode(green_front, 1)

    wiringpi.softPwmCreate(red_front, OFF, ON)
    wiringpi.softPwmCreate(blue_front, OFF, ON)
    wiringpi.softPwmCreate(green_front, OFF, ON)
    wiringpi.softPwmCreate(red_back, OFF, ON)
    wiringpi.softPwmCreate(blue_back, OFF, ON)
    wiringpi.softPwmCreate(green_back, OFF, ON)
Beispiel #23
0
blue = 0
green = 0
select = 0

SPI_CH = 0
READ_CH = 0

pi.wiringPiSetupGpio()
pi.pinMode( green_pin, 1 )
pi.pinMode( blue_pin, 1 )
pi.pinMode( red_pin, 1 )

pi.pinMode( button_pin, 0 )
pi.pullUpDnControl( button_pin, 2 )

pi.softPwmCreate( green_pin, 0, 100 )
pi.softPwmCreate( blue_pin, 0, 100 )
pi.softPwmCreate( red_pin, 0, 100 )

mcp3002 = mcp3002( pi, SPI_CH )

while True:
	if ( pi.digitalRead( button_pin ) == 0 ):
		time.sleep( 0.01 )
		if ( select == 0 ):
			select = 1
			print( "Control Green." )
		elif ( select == 1 ):
			select = 2
			print( "Control Blue." )
		elif ( select == 2 ):
Beispiel #24
0
# Servo Control
import time
import wiringpi

PIN_TO_PWM = 23
PIN_TO_PWM2 = 24

wiringpi.wiringPiSetupGpio()
OUTPUT = 1

wiringpi.pinMode(PIN_TO_PWM, OUTPUT)
wiringpi.softPwmCreate(PIN_TO_PWM, 50, 1000)
wiringpi.pinMode(PIN_TO_PWM2, OUTPUT)
wiringpi.softPwmCreate(PIN_TO_PWM2, 50, 1000)

try:
    while True:

        val = int(raw_input())
        val2 = int(raw_input())
        wiringpi.softPwmWrite(PIN_TO_PWM, val)
        wiringpi.delay(10)
        wiringpi.softPwmWrite(PIN_TO_PWM2, val2)
        wiringpi.delay(10)

finally:
    wiringpi.softPwmWrite(PIN_TO_PWM, 15)
    wiringpi.softPwmWrite(PIN_TO_PWM2, 15)
def init_raspberry_pins():
    wp.wiringPiSetup()
    wp.softPwmCreate(robot_api['pwm_left_pin'], 0, robot_api['pwm_range'])
    wp.softPwmCreate(robot_api['pwm_right_pin'], 0, robot_api['pwm_range'])
    wp.pinMode(robot_api['dir_left_pin'], wp.OUTPUT)
    wp.pinMode(robot_api['dir_right_pin'], wp.OUTPUT)
Beispiel #26
0
def Servo(pin):
	wp.pinMode(pin,1)
	wp.softPwmCreate(pin,0,100)
	return pin
Beispiel #27
0
#
# 02_led_wiringpi_softpwm.py
#

import wiringpi

LED_PORT = 18
PWM_RANGE = 100

# Software PWM
wiringpi.wiringPiSetupGpio()
wiringpi.pinMode(LED_PORT, wiringpi.GPIO.PWM_OUTPUT)
wiringpi.softPwmCreate(LED_PORT, 0, PWM_RANGE)

# LEDを2秒間点灯する
for duty in (5, 20, 50, 80, 100):
    print(duty)
    wiringpi.softPwmWrite(LED_PORT, duty)
    wiringpi.delay(2000)

wiringpi.softPwmStop(LED_PORT)

print('done')
Beispiel #28
0
import wiringpi as pi, time
import webiopi

servo_pin = 23
waittime = 0.03

pi.wiringPiSetupGpio()

pi.pinMode(servo_pin, pi.OUTPUT)
pi.softPwmCreate(servo_pin, 0, 50)


def moveleft(pin):
    for i in range(27, 5, -1):
        time.sleep(waittime)
        pi.softPwmWrite(pin, i)


def moveright(pin):
    for i in range(5, 27, 1):
        time.sleep(waittime)
        pi.softPwmWrite(pin, i)


for i in range(3):
    moveleft(servo_pin)
    moveright(servo_pin)

pi.softPwmWrite(servo_pin, 0)
Beispiel #29
0
def _start():
    '''Start the module
    This uses the global variables from setup and adds a set of global variables
    '''
    global parser, args, config, r, response, patch, name
    global monitor, pin, debug, delay, scale_duration, offset_duration, lock, trigger

    # this can be used to show parameters that have changed
    monitor = EEGsynth.monitor(name=name, debug=patch.getint('general', 'debug'))

    # make a dictionary that maps GPIOs to the WiringPi number
    pin = {
        "gpio0": 0,
        "gpio1": 1,
        "gpio2": 2,
        "gpio3": 3,
        "gpio4": 4,
        "gpio5": 5,
        "gpio6": 6,
        "gpio7": 7,
        "gpio21": 21,
        "gpio22": 22,
        "gpio23": 23,
        "gpio24": 24,
        "gpio25": 25,
        "gpio26": 26,
        "gpio27": 27,
        "gpio28": 28,
        "gpio29": 29,
    }

    # get the options from the configuration file
    debug = patch.getint('general', 'debug')
    delay = patch.getfloat('general', 'delay')

    # values between 0 and 1 work well for the duration
    scale_duration = patch.getfloat('scale', 'duration', default=1)
    offset_duration = patch.getfloat('offset', 'duration', default=0)

    # this is to prevent two triggers from being activated at the same time
    lock = threading.Lock()

    # use the WiringPi numbering, see http://wiringpi.com/reference/setup/
    wiringpi.wiringPiSetup()

    # set up PWM for the control channels
    previous_val = {}
    for gpio, channel in config.items('control'):
        monitor.info("control " + channel + " " + gpio)
        wiringpi.softPwmCreate(pin[gpio], 0, 100)
        # control values are only relevant when different from the previous value
        previous_val[gpio] = None

    # create the threads that deal with the triggers
    trigger = []
    for gpio, channel in config.items('trigger'):
        wiringpi.pinMode(pin[gpio], 1)
        duration = patch.getstring('duration', gpio)
        trigger.append(TriggerThread(channel, gpio, duration))
        monitor.info("trigger " + channel + " " + gpio)

    # start the thread for each of the triggers
    for thread in trigger:
        thread.start()

    # there should not be any local variables in this function, they should all be global
    if len(locals()):
        print('LOCALS: ' + ', '.join(locals().keys()))
import wiringpi
import time

#GPIO_WIRING_PIN = 1 # gpio pin 12 = wiringpi no. 1 (BCM 18)
GPIO_BCM = 18

#Initialize HW PWM
#wiringpi.wiringPiSetup()
#wiringpi.pinMode(GPIO_BCM, 2)     # PWM mode
#wiringpi.pwmWrite(GPIO_BCM, 0)    # OFF

#Initialize SW PWM
wiringpi.wiringPiSetupGpio()
wiringpi.pinMode(GPIO_BCM, 2)     # PWM mode
wiringpi.softPwmCreate(GPIO_BCM,0,200) # Setup PWM using Pin, Initial Value and Range parameters

# Set PWM
def pwm(value):
    #HW PWM
    #wiringpi.pwmWrite(GPIO_BCM, value)
    #SW PWM
    wiringpi.softPwmWrite(GPIO_BCM, value)

print "PWM 0"
for i in range(5,18):
    pwm(i)
    print i
    time.sleep(1)
pwm(0)
Beispiel #31
0
import time, wiringpi as pi

led_pin = 14

pi.wiringPiSetupGpio()
pi.pinMode( led_pin, pi.OUTPUT )

pi.softPwmCreate( led_pin, 0, 100)
pi.softPwmWrite( led_pin, 0 )

while True:
    strong = 0
    while ( strong <= 100 ):
        pi.softPwmWrite( led_pin, strong )
        time.sleep(0.1)
        strong = strong + 1

    pi.softPwmWrite( led_pin, 0 )
    time.sleep(2)

Beispiel #32
0
 def setPinConfig(self, EN, INA, INB):
     wiringpi.pinMode(EN, self.OUTPUT)
     wiringpi.pinMode(INA, self.OUTPUT)
     wiringpi.pinMode(INB, self.OUTPUT)
     wiringpi.softPwmCreate(EN, 0, 255)
HSV_Lower_White = (7,15,240)
HSV_Upper_White = (30,0,255)

wp.wiringPiSetupGpio()                                         #WiringPi setup and all gpio pins initialized 

m1x=26
m1y=20
m2x=19
m2y=16
m1e=13
m2e=21

wp.pinMode(m1x,1)                                              #Motor 1 and Motor 2 - Forward,Backward and Enabler pin Setup
wp.pinMode(m1y,1)
wp.softPwmCreate(m1e,0,100)
wp.pinMode(m2x,1)
wp.pinMode(m2y,1)
wp.softPwmCreate(m2e,0,100)

def forward(dist):
        wp.digitalWrite(m1x,0)
        wp.digitalWrite(m1y,1)
        wp.digitalWrite(m2x,1)
        wp.digitalWrite(m2y,0)

        wp.softPwmWrite(m1e,20)
        wp.softPwmWrite(m2e,25)

        print('Moving forward')
        time.sleep(dist)
Beispiel #34
0
import wiringpi as wpi
PIN_LED = 18

wpi.wiringPiSetupGpio()
wpi.pinMode(PIN_LED, wpi.OUTPUT)
wpi.softPwmCreate(PIN_LED, 0, 100)

while True:
    for i in range(0, 101):
        wpi.softPwmWrite(PIN_LED, i)
        wpi.delay(10)

    for i in range(100, -1, -1):
        wpi.softPwmWrite(PIN_LED, i)
        wpi.delay(10)
Beispiel #35
0
# Pulsates an LED connected to GPIO pin 1 with a suitable resistor 4 times using softPwm
# softPwm uses a fixed frequency
import wiringpi

OUTPUT = 1

PIN_TO_PWM = 23
PIN_TO_PWM2 = 24

wiringpi.wiringPiSetupGpio()

wiringpi.pinMode(PIN_TO_PWM, OUTPUT)
wiringpi.softPwmCreate(
    PIN_TO_PWM, 0,
    100)  # Setup PWM using Pin, Initial Value and Range parameters
wiringpi.pinMode(PIN_TO_PWM2, OUTPUT)
wiringpi.softPwmCreate(PIN_TO_PWM2, 0, 100)
wiringpi.softPwmWrite(PIN_TO_PWM, 15)
wiringpi.softPwmWrite(PIN_TO_PWM2, 15)
wiringpi.delay(20)

try:
    while True:
        for brightness in range(5, 25):
            wiringpi.softPwmWrite(PIN_TO_PWM,
                                  brightness)  # Change PWM duty cycle
            wiringpi.delay(20)  # Delay for 0.2 seconds
        for brightness in reversed(range(5, 25)):
            wiringpi.softPwmWrite(PIN_TO_PWM2, brightness)
            wiringpi.delay(20)
        for brightness in range(5, 25):
Beispiel #36
0
import time
import wiringpi
wiringpi.wiringPiSetup()

wiringpi.pinMode(1, 1)
wiringpi.softPwmCreate(1, 0, 100)
wiringpi.softPwmWrite(1, 0)

wiringpi.pinMode(4, 1)
wiringpi.softPwmCreate(4, 0, 100)
wiringpi.softPwmWrite(4, 0)

wiringpi.pinMode(5, 1)
wiringpi.softPwmCreate(5, 0, 100)
wiringpi.softPwmWrite(5, 0)

wiringpi.pinMode(6, 1)
wiringpi.softPwmCreate(6, 0, 100)
wiringpi.softPwmWrite(6, 0)


def forward(speed):
    if speed >= 100:
        speed = 100
        wiringpi.softPwmWrite(1, 0)
        wiringpi.softPwmWrite(4, speed)
        wiringpi.softPwmWrite(5, 0)
        wiringpi.softPwmWrite(6, speed)
    elif speed < 0:
        speed = abs(speed)
        wiringpi.softPwmWrite(1, speed)
Beispiel #37
0
                        duration = patch.getfloat('duration', self.gpio)
                        duration = EEGsynth.rescale(duration, slope=duration_scale, offset=duration_offset)
                        # some minimal time is needed for the delay
                        duration = EEGsynth.limit(duration, 0.05, float('Inf'))
                        t = threading.Timer(duration, SetGPIO, args=[self.gpio, 0])
                        t.start()


# use the WiringPi numbering, see http://wiringpi.com/reference/setup/
wiringpi.wiringPiSetup()

# set up PWM for the control channels
previous_val = {}
for gpio, channel in config.items('control'):
    print("control", channel, gpio)
    wiringpi.softPwmCreate(pin[gpio], 0, 100)
    # control values are only relevant when different from the previous value
    previous_val[gpio] = None

# create the threads that deal with the triggers
trigger = []
for gpio, channel in config.items('trigger'):
    wiringpi.pinMode(pin[gpio], 1)
    try:
        duration = patch.getstring('duration', gpio)
    except:
        duration = None
    trigger.append(TriggerThread(channel, gpio, duration))
    print("trigger", channel, gpio)

# start the thread for each of the triggers
Beispiel #38
0
	wiringpi.softPwmWrite(enableA, 255)
	wiringpi.digitalWrite(h1, 1)
	wiringpi.digitalWrite(h2, 0)
	wiringpi.softPwmWrite(enableB, 255)
	wiringpi.digitalWrite(h3, 0)
	wiringpi.digitalWrite(h4, 1)


wiringpi.wiringPiSetup()
wiringpi.pinMode(enableA, 1)
wiringpi.pinMode(h1, 1)
wiringpi.pinMode(h2, 1)
wiringpi.pinMode(enableB, 1)
wiringpi.pinMode(h3, 1)
wiringpi.pinMode(h4, 1)
wiringpi.softPwmCreate(enableA, 0, 255)
wiringpi.softPwmCreate(enableB, 0, 255)
wiringpi.pinMode(obsA, wiringpi.INPUT)
wiringpi.pinMode(obsB, wiringpi.INPUT)


mthread = startMouse()

while True:
	valueA = wiringpi.digitalRead(obsA)
	valueB = wiringpi.digitalRead(obsB)

	#print 'obsA:', valueA, 'obsB:', valueB

	if valueA == 0 or valueB == 0:
		if direction == 'Pause':
Beispiel #39
0
 def _gpio_setup(self):
     wiringpi.wiringPiSetup()
     wiringpi.pinMode(AC_LOAD_PIN, 1)
     wiringpi.softPwmCreate(AC_LOAD_PIN, LEVEL_MIN, LEVEL_MAX)
Beispiel #40
0
clock = int(19.2 / float(RANGE) * CYCLE * 1000)
SERVO_MIN_VALUE = int(SERVO_MIN * RANGE / CYCLE)
SERVO_MAX_VALUE = int(SERVO_MAX * RANGE / CYCLE)

pi.wiringPiSetupGpio()
pi.pinMode(blue_right_pin, pi.OUTPUT)
pi.pinMode(green_right_pin, pi.OUTPUT)
pi.pinMode(red_right_pin, pi.OUTPUT)
pi.pinMode(blue_left_pin, pi.OUTPUT)
pi.pinMode(green_left_pin, pi.OUTPUT)
pi.pinMode(red_left_pin, pi.OUTPUT)
pi.pinMode(blue_center_pin, pi.OUTPUT)
pi.pinMode(green_center_pin, pi.OUTPUT)
pi.pinMode(red_center_pin, pi.OUTPUT)

pi.softPwmCreate(blue_right_pin, 0, 100)
pi.softPwmCreate(green_right_pin, 0, 100)
pi.softPwmCreate(red_right_pin, 0, 100)
pi.softPwmCreate(blue_left_pin, 0, 100)
pi.softPwmCreate(green_left_pin, 0, 100)
pi.softPwmCreate(red_left_pin, 0, 100)
pi.softPwmCreate(blue_center_pin, 0, 100)
pi.softPwmCreate(green_center_pin, 0, 100)
pi.softPwmCreate(red_center_pin, 0, 100)

pi.pinMode(servo_pin, pi.GPIO.PWM_OUTPUT)
pi.pwmSetMode(pi.GPIO.PWM_MODE_MS)
pi.pwmSetRange(RANGE)
pi.pwmSetClock(clock)

for num in range(1, 4):
Beispiel #41
0
                        duration = patch.getfloat('duration', self.gpio)
                        duration = EEGsynth.rescale(duration, slope=scale_duration, offset=offset_duration)
                        # some minimal time is needed for the delay
                        duration = EEGsynth.limit(duration, 0.05, float('Inf'))
                        t = threading.Timer(duration, SetGPIO, args=[self.gpio, 0])
                        t.start()


# use the WiringPi numbering, see http://wiringpi.com/reference/setup/
wiringpi.wiringPiSetup()

# set up PWM for the control channels
previous_val = {}
for gpio, channel in config.items('control'):
    print("control", channel, gpio)
    wiringpi.softPwmCreate(pin[gpio], 0, 100)
    # control values are only relevant when different from the previous value
    previous_val[gpio] = None

# create the threads that deal with the triggers
trigger = []
for gpio, channel in config.items('trigger'):
    wiringpi.pinMode(pin[gpio], 1)
    try:
        duration = patch.getstring('duration', gpio)
    except:
        duration = None
    trigger.append(TriggerThread(channel, gpio, duration))
    print("trigger", channel, gpio)

# start the thread for each of the triggers
Beispiel #42
0
import wiringpi

print "Testing..."
wiringpi.delay(1000)
print "..1.."
wiringpi.delay(1000)
print "..2.."
wiringpi.delay(1000)
print "...3!"
print "Testing under progress"

OUTPUT = 2
SERVO_G4 = 4

print "Setting up wiringPi"
wiringpi.wiringPiSetup()

print "Setting PWM Output on G4"
wiringpi.pinMode(4, 2)
wiringpi.softPwmCreate(SERVO_G4, 0, 100)

print "Going through PWM ranges"
for r in range(0, 100):
    wiringpi.softPwmWrite(SERVO_G4, r)
    wiringpi.delay(100)
Beispiel #43
0
# frontRight: A = purple, B = blue, PWM = green
robot.frontRight = Motor(A=22, B=27, pwmPin=15, duty=60, range=pwm_range)

########################

# Hardware PWM - for shooter servo
pwmPin = 18 # Broadcom pin 18 (P1 pin 12)
GPIO.setup(pwmPin, GPIO.OUT) # PWM pin set as output
pwm = GPIO.PWM(pwmPin, 50)  # Initialize PWM
pwm.start(dc) # Initial state

########################

# Software PWM
wiringpi.wiringPiSetupGpio()
wiringpi.softPwmCreate(robot.rearLeft.softPWM, robot.rearLeft.val, robot.rearLeft.range)
wiringpi.softPwmCreate(robot.rearRight.softPWM, robot.rearRight.val, robot.rearRight.range)
wiringpi.softPwmCreate(robot.frontLeft.softPWM, robot.frontLeft.val, robot.frontLeft.range)
wiringpi.softPwmCreate(robot.frontRight.softPWM, robot.frontRight.val, robot.frontRight.range)

########################

## Shooter Process

class ShooterThread (threading.Thread):
    def __init__(self):
        threading.Thread.__init__(self)
        self.servo = Servo()
        self.servo.update(30)

    def run(self):
Beispiel #44
0
# Servo Control
import time
import wiringpi

# set the PWM mode to milliseconds stype
wiringpi.pwmSetMode(wiringpi.GPIO.PWM_MODE_MS)
PIN_TO_PWM = 24
PIN_TO_PWM2 = 23


wiringpi.wiringPiSetupGpio()
OUTPUT = 1
val = 15
wiringpi.pinMode(PIN_TO_PWM,OUTPUT)
wiringpi.softPwmCreate(PIN_TO_PWM,15,25)
wiringpi.pinMode(PIN_TO_PWM2,OUTPUT)
wiringpi.softPwmCreate(PIN_TO_PWM2,14,25)

#wiringpi.softPwmWrite(PIN_TO_PWM, 15)
#wiringpi.softPwmWrite(PIN_TO_PWM2, 15)

writeval = 14
#wiringpi.softPwmWrite(PIN_TO_PWM2,writeval)
wiringpi.delay(20)
#wiringpi.softPwmWrite(PIN_TO_PWM2,writeval)
wiringpi.delay(20)

# set the PWM mode to milliseconds stype
while True:
	try:
Beispiel #45
0
    def __init__(self, communication_style = "WIFI"):
        # parameters
        self.communication_style = communication_style
        self.HOST = ''
        self.CONNECTION_PORT = 2525


        self.DRIVING_PORT = 2526
        self.DRIVING_SERVICE_UUID = "94f39d29-7d6d-437d-973b-fba39e49d4ed"

        self.SONAR_PORT = 2527

        self.CAMERA_PORT = 2528

        self.CAMERA_DRIVING_PORT = 2529
        self.CAMERA_DRIVING_SERVICE_UUID = "94f39d29-7d6d-437d-973b-fba39e49d4ec"


        # MOTORS' PINS ----> still to be set correctly
        # Nomenclature: _F : forward     _B : backward
        self.MOTOR_LEFT_F = 7
        self.MOTOR_LEFT_B = 11
        self.MOTOR_RIGHT_F = 15
        self.MOTOR_RIGHT_B = 13
        # we know map them to the wiringPi gpio map
        # http://wiringpi.com/pins/
        self.MOTOR_LEFT_F = mapGPIO2WIRINGPI(self.MOTOR_LEFT_F)
        self.MOTOR_LEFT_B = mapGPIO2WIRINGPI(self.MOTOR_LEFT_B)
        self.MOTOR_RIGHT_F = mapGPIO2WIRINGPI(self.MOTOR_RIGHT_F)
        self.MOTOR_RIGHT_B = mapGPIO2WIRINGPI(self.MOTOR_RIGHT_B)


        # STATE OF THE ROBOT
        # The possible states are:
        # IDLE : don't move
        # FORWARD : moving forward
        # BACKWARD : moving backward
        # TURNING_LEFT : turning left
        # TURNING_RIGHT : turning right
        self.state = 'IDLE'
        # Then these states are enriched by the velocity for each well
        self.MAX_SPEED = 100
        self.MIN_SPEED = 70
        self.velocity_left_weel = 0
        self.velocity_right_weel = 0

        # The "connection socket" is the one with the only aim to establish a connection to the computer
        if self.communication_style == "WIFI":
            self.connection_socket = udpsocket.UDPSocket()
            # We make all the sockets as servers here for the robot. Once they have binded they can be used for normal communication
            self.connection_socket.bind(self.CONNECTION_PORT, self.HOST)
        else:
            self.connection_socket = bluetooth.BluetoothSocket( bluetooth.RFCOMM )
            # bind the socket to an address, this format bounds the socket to any port and any address. You can bound the socket to a specific address and a specific port.
            self.connection_socket.bind(("", bluetooth.PORT_ANY))
            # Listen to connections made to the socket. The argument specified the maximum number of queded connections. It has to be at least 0 but in that case it does not listen anyone.
            self.connection_socket.listen(1)

        # The "driving socket" has the aim to receive data regarding the driving of the robot (direction and velocity)
        if self.communication_style == "WIFI":
            self.driving_socket = udpsocket.UDPSocket()
            self.driving_socket.bind(self.DRIVING_PORT, self.HOST)
        else:
            self.driving_socket = bluetooth.BluetoothSocket( bluetooth.RFCOMM )
            # bind the socket to an address, this format bounds the socket to any port and any address. You can bound the socket to a specific address and a specific port.
            self.driving_socket.bind(("", bluetooth.PORT_ANY))
            # Listen to connections made to the socket. The argument specified the maximum number of queded connections. It has to be at least 0 but in that case it does not listen anyone.
            self.driving_socket.listen(1)

        # The "driving socket" has the aim to receive data regarding the driving of the robot (direction and velocity)
        if self.communication_style == "WIFI":
            self.camera_driving_socket = udpsocket.UDPSocket()
            self.camera_driving_socket.bind(self.CAMERA_DRIVING_PORT, self.HOST)
        else:
            self.camera_driving_socket = bluetooth.BluetoothSocket(bluetooth.RFCOMM)
            # bind the socket to an address, this format bounds the socket to any port and any address. You can bound the socket to a specific address and a specific port.
            self.camera_driving_socket.bind(("", bluetooth.PORT_ANY))
            # Listen to connections made to the socket. The argument specified the maximum number of queded connections. It has to be at least 0 but in that case it does not listen anyone.
            self.camera_driving_socket.listen(1)




        # The "sonar socket" send data regarding the measurement of the SONAR
        self.sonar_socket = udpsocket.UDPSocket()
        self.sonar_socket.bind(self.SONAR_PORT, self.HOST)

        # The "picamera socket" send data regarding the picamera
        self.picamera_socket = udpsocket.UDPSocket()
        self.picamera_socket.bind(self.CAMERA_PORT, self.HOST)

        # set up the wiringPi library
        wiringpi.wiringPiSetup()
        wiringpi.pinMode(self.MOTOR_LEFT_F, 1)
        wiringpi.pinMode(self.MOTOR_LEFT_B, 1)
        wiringpi.pinMode(self.MOTOR_RIGHT_F, 1)
        wiringpi.pinMode(self.MOTOR_RIGHT_B, 1)
        wiringpi.softPwmCreate(self.MOTOR_LEFT_F, 0, 100)
        wiringpi.softPwmCreate(self.MOTOR_LEFT_B, 0, 100)
        wiringpi.softPwmCreate(self.MOTOR_RIGHT_F, 0, 100)
        wiringpi.softPwmCreate(self.MOTOR_RIGHT_B, 0, 100)

        # CAMERA SERVO MOTORS -----------------------------------
        # set pwm for servo motors (motor for the camera)
        self.yaw_motor_pin = 12
        self.pitch_motor_pin = 16
        self.PWM_FREQUENCY = 50 # Hz
        self.camera_motors_max_time = 0.3 #sec  - Maximum time to send a pwm (for noise reduction)
        GPIO.setmode(GPIO.BOARD)
        GPIO.setup(self.yaw_motor_pin, GPIO.OUT)
        GPIO.setup(self.pitch_motor_pin, GPIO.OUT)
        self.yaw_motor_pwm = GPIO.PWM(self.yaw_motor_pin,self.PWM_FREQUENCY )
        self.yaw_motor_pwm.start(0.0)
        self.pitch_motor_pwm = GPIO.PWM(self.pitch_motor_pin, self.PWM_FREQUENCY)
        self.pitch_motor_pwm.start(0.0)

        # initial angle
        self.yaw_angle = 0
        self.pitch_angle = 0
        self.PULSES2DEGREE = 180/200 # 180 degree/ 200 pulses
        self.yaw_angle_old = self.yaw_angle
        self.pitch_angle_old = self.pitch_angle
        self.new_yaw_angle = False # this is set to true when tehre is a new yaw angle
        self.new_yaw_angle_arrived = time.time() # time at which the new yaw angle arrived
        self.new_pitch_angle = False
        self.new_pitch_angle_arrived = time.time()


        # the servo motors are controlled with pulses, from 50 to 250
        # we use the term pulse because it refers to the pwm with (50=0.5ms,250=2.5ms)
        # we are going to set the zero value of the servo with the central pulse
        # ideally 50 is -90 degree and 250 is + 90 degree (- is on the rigth for the yaw, and down for the pitch)
        self.yaw_angle_zero_pulse = 140
        self.pitch_angle_zero_pulse = 145
        # iF the zero values are not perfectly calibrated to 150 we are going to center with saturation values
        self.yaw_range_pulse = min( self.yaw_angle_zero_pulse - 50, 250 - self.yaw_angle_zero_pulse)
        self.yaw_max_pulse = self.yaw_angle_zero_pulse + self.yaw_range_pulse + 50
        self.yaw_min_pulse = self.yaw_angle_zero_pulse - self.yaw_range_pulse
        self.pitch_range_pulse = min(self.pitch_angle_zero_pulse - 50, 250 - self.pitch_angle_zero_pulse)
        self.pitch_max_pulse = self.pitch_angle_zero_pulse + self.pitch_range_pulse + 50
        self.pitch_min_pulse = self.pitch_angle_zero_pulse - self.pitch_range_pulse

        # 180degree/200pulses = degree/pulses is the resolution
        self.yaw_range_degree = 180/200 * 2 * self.yaw_range_pulse
        self.pitch_range_degree = 180/200 * 2 * self.pitch_range_pulse
        self.yaw_max_angle = self.yaw_range_degree/2
        self.yaw_min_angle = - self.yaw_max_angle
        self.pitch_max_angle = self.pitch_range_degree / 2
        self.pitch_min_angle = - self.pitch_max_angle
        print "YAW/PITCH RANGES [+/-degree]: ", self.yaw_range_degree/2, "/",self.pitch_range_degree/2

        # let's give the motors 0.3s to set to the zero position
        # we have to give it some times to reach a certain position
        # but we have to stop after sometime the motors because of noise problem
        t_start = time.time()
        yaw_duty_cycle = (self.yaw_angle_zero_pulse / 1000) * self.PWM_FREQUENCY
        pitch_duty_cycle = (self.pitch_angle_zero_pulse / 1000) * self.PWM_FREQUENCY
        while time.time() - t_start <= 0.3:
            #self.yaw_motor_pwm.ChangeDutyCycle(yaw_duty_cycle)
            self.yaw_motor_pwm.ChangeDutyCycle(self.yawDegreeToDutyCycle(0.0))
            self.pitch_motor_pwm.ChangeDutyCycle(self.pitchDegreeToDutyCycle(0.0))
            #self.pitch_motor_pwm.ChangeDutyCycle(pitch_duty_cycle)
        self.yaw_motor_pwm.ChangeDutyCycle(0.0)
        self.pitch_motor_pwm.ChangeDutyCycle(0.0)
Beispiel #46
0
import time

# pin: 11, 12, 15, 16
# BCM: 17, 18, 22, 23
front_l = 17
front_r = 18
back_l = 22
back_r = 23

pi.wiringPiSetupGpio()
pi.pinMode(front_l, pi.OUTPUT)
pi.pinMode(front_r, pi.OUTPUT)
pi.pinMode(back_l, pi.OUTPUT)
pi.pinMode(back_r, pi.OUTPUT)

pi.softPwmCreate(front_l, 0, 100)
pi.softPwmWrite(front_l, 0)

pi.softPwmCreate(front_r, 0, 100)
pi.softPwmWrite(front_r, 0)

pi.softPwmCreate(back_l, 0, 100)
pi.softPwmWrite(back_l, 0)

pi.softPwmCreate(back_r, 0, 100)
pi.softPwmWrite(back_r, 0)

try:
    while True:
        speed = 20
        pi.softPwmWrite(front_l, speed)
Beispiel #47
0
	def __init__(self):
		rospy.init_node('gpio')
		rospy.loginfo("Starting GPIO ROS Driver")
                #os.system('/home/pi/phri_ros/scripts/setup_gpio')
		os.system(os_setup)

                self.io = wp.GPIO(wp.GPIO.WPI_MODE_SYS)

                self.pwm_range = 50
                self.button_Hz = 20.0
                self.button_offtime = rospy.Duration(4.0)

                rospy.loginfo("Starting Soft PWM Timers")
                wp.softPwmCreate(17, 0, self.pwm_range)
                wp.softPwmCreate(18, 0, self.pwm_range)
                wp.softPwmCreate(21, 0, self.pwm_range)

                wp.softPwmCreate(22, 0, self.pwm_range)
		self.io.digitalWrite(23,1)
		self.io.digitalWrite(24,0)

                wp.softPwmCreate(25, 0, self.pwm_range)
		self.io.digitalWrite(10,0)
		self.io.digitalWrite(9,0)

                wp.softPwmCreate(11, 0, self.pwm_range)
                wp.softPwmCreate(8, 0, self.pwm_range)
                wp.softPwmCreate(7, 0, self.pwm_range)

		self.leye_sub = rospy.Subscriber("left_eye", ColorRGBA, self.leye)
		self.reye_sub = rospy.Subscriber("right_eye", ColorRGBA, self.reye)

		self.l_motor_sub = rospy.Subscriber("left_motor", Float32, self.lmotor)
		self.r_motor_sub = rospy.Subscriber("right_motor", Float32, self.rmotor)

		self.twistsub = rospy.Subscriber("cmd_vel", Twist, self.twistCallback)

		self.button_pub = rospy.Publisher("buttons", Bool)


                rospy.loginfo("Starting Button Query Timers")		
		rospy.Timer(rospy.Duration(1.0/self.button_Hz), self.check_buttons)
		
		self.yes_time = rospy.Time()
		self.no_time = rospy.Time()
pinblue = 12
pingreen = 5

red = [255, 0, 0]
orange = [255, 127, 0]
yellow = [255, 255, 0]
white = [255, 255, 255]
green = [0, 255, 0]
blue = [0, 0, 255]
i = [75, 0, 130]
v = [159, 0, 255]
black = [0, 0, 0]

wiringpi.wiringPiSetupGpio()
wiringpi.pinMode(pinred, OUTPUT)  # as output
wiringpi.softPwmCreate(
    pinred, 0, 255)  # Setup PWM using Pin, Initial Value and Range parameters
wiringpi.pinMode(pingreen, OUTPUT)  # as output
wiringpi.softPwmCreate(
    pingreen, 0,
    255)  # Setup PWM using Pin, Initial Value and Range parameters
wiringpi.pinMode(pinblue, OUTPUT)  # as output
wiringpi.softPwmCreate(
    pinblue, 0, 255)  # Setup PWM using Pin, Initial Value and Range parameters

color = black
if sys.argv[1]:
    farbe = str(sys.argv[1])
    brightness = int(100)
    try:
        print(len(sys.argv))
        if len(sys.argv) > 2:
Beispiel #49
0
	def __init(self):
		self.gpio = wiringpi.wiringPiSetup()		
		wiringpi.softPwmCreate(PIN_RED,   0, LED_MAX)
		wiringpi.softPwmCreate(PIN_GREEN, 0, LED_MAX)
		wiringpi.softPwmCreate(PIN_BLUE,  0, LED_MAX)
		self.off()
Beispiel #50
0
def setPinConfig(EN, INA , INB):
    wiringpi.pinMode(EN, OUTPUT)
    wiringpi.pinMode(INA, OUTPUT)
    wiringpi.pinMode(INB, OUTPUT)
    wiringpi.softPwmCreate(EN, 0, 255)