def __init__(self):
        """
        Init the pins in the right mode and init the modules that require it.
        """
        try:
            import grovepi
        except ImportError:
            print("Module GrovePi does not exist. Running in sandbox mode.")
            print("No actions will be taken regarding the sensors.")
            return
        import time

        # Analog ports
        self.analog_temperature = 0
        self.air_sensor = 1
        self.sound_sensor = 2

        # Digital ports
        self.led_pin = 7

        self.nb_leds = 1
        self.led_is_on = False

        grovepi.pinMode(self.led_pin, "OUTPUT")
        grovepi.pinMode(self.air_sensor, "INPUT")
        time.sleep(1) # Just in case
        grovepi.chainableRgbLed_init(self.led_pin, self.nb_leds)
        # change color to green
        grovepi.storeColor(0, 255, 0)
예제 #2
0
def initalize_chained_led():
    print("Test 1) Initialise")

    # init chain of leds
    grovepi.chainableRgbLed_init(ledpin, numleds)
    time.sleep(.5)

    grovepi.chainableRgbLed_test(ledpin, numleds, random.randint(0, 7))
    time.sleep(.5)
예제 #3
0
파일: robot.py 프로젝트: CleoQc/GrovePi
def initalize_chained_led():
		print("Test 1) Initialise")

		# init chain of leds
		grovepi.chainableRgbLed_init(ledpin, numleds)
		time.sleep(.5)

		grovepi.chainableRgbLed_test(ledpin, numleds, random.randint(0,7))
		time.sleep(.5)
예제 #4
0
def setupIO():
    # Initialisation des entrées sorties sur le GrovePi #
    grovepi.pinMode(relay_pin,"OUTPUT")
    grovepi.pinMode(RGB_pin,"OUTPUT")
    grovepi.pinMode(PIR_pin, "INPUT")
    grovepi.chainableRgbLed_init(RGB_pin,8)
    
    # On génère un PWM hardware de fréquence 50Hz #
    # La largeur de l'impulsion est entre 0,8 et 2ms #
    wiringPi.wiringPiSetupGpio()
    wiringPi.pinMode(PWM_GPIO, 2)
    wiringPi.pwmSetMode(0)
    wiringPi.pwmSetClock(384)
    wiringPi.pwmSetRange(1024)
    wiringPi.pwmWrite(PWM_GPIO,75)
testColorMagenta = 5 # 0b101 #FF00FF
testColorYellow = 6  # 0b110 #FFFF00
testColorWhite = 7   # 0b111 #FFFFFF

# patterns used in grovepi.chainableRgbLed_pattern()
thisLedOnly = 0
allLedsExceptThis = 1
thisLedAndInwards = 2
thisLedAndOutwards = 3

try:

    print("Test 1) Initialise")

    # init chain of leds
    grovepi.chainableRgbLed_init(pin, numleds)
    time.sleep(.5)

    # change color to green
    grovepi.storeColor(0,255,0)
    time.sleep(.5)

    # set led 1 to green
    grovepi.chainableRgbLed_pattern(pin, thisLedOnly, 0)
    time.sleep(.5)

    # change color to red
    grovepi.storeColor(255,0,0)
    time.sleep(.5)

    # set led 10 to red
예제 #6
0
        t = threading.Timer(
                self._interval,
                self._function,
                *self._args,
                **self._kwargs
                )
        t.start()


# main
if __name__ == '__main__':
    # Init LED
    grovepi.digitalWrite(feedbackLEDPort, 0)
    
    # Init Chainable RGB LED
    grovepi.chainableRgbLed_init(rgbLEDPort, num_of_leds)
    
    # Create threading object
    # radio_timer = MyThreading(5400, kill_mplayer)
    rgbled_timer = MyThreading(40, return_color, ())
    
    # Init mplayer
    kill_mplayer()
    
    # start up blink
    startup_blink = [7,6,5,4,3,2,1,0,7]
    for i in startup_blink:
        grovepi.chainableRgbLed_test(rgbLEDPort, num_of_leds, i)
        time.sleep(.1)
    
    [new_val, encoder_val] = grovepi.encoderRead()
예제 #7
0
testColorMagenta = 5 # 0b101 #FF00FF
testColorYellow = 6  # 0b110 #FFFF00
testColorWhite = 7   # 0b111 #FFFFFF

# patterns used in grovepi.chainableRgbLed_pattern()
thisLedOnly = 0
allLedsExceptThis = 1
thisLedAndInwards = 2
thisLedAndOutwards = 3

try:

    print "Test 1) Initialise"

    # init chain of leds
    grovepi.chainableRgbLed_init(pin, numleds)
    time.sleep(.5)

    # change color to green
    grovepi.storeColor(0,255,0)
    time.sleep(.5)

    # set led 1 to green
    grovepi.chainableRgbLed_pattern(pin, thisLedOnly, 0)
    time.sleep(.5)

    # change color to red
    grovepi.storeColor(255,0,0)
    time.sleep(.5)

    # set led 10 to red
예제 #8
0
 def __init__(self, pin):
     self.pin = pin
     grovepi.pinMode(self.pin,'OUTPUT')
     grovepi.chainableRgbLed_init(self.pin, 1)
     grovepi.storeColor(0, 255, 0)
예제 #9
0
 def __init__(self, pin):
     self.pin = pin
     grovepi.pinMode(pin, "OUTPUT")
     grovepi.chainableRgbLed_init(pin, 1)
예제 #10
0
#!/usr/bin/python
import gamepad
from mainloop import MainLoop
import sys,time,os

# grovepi init
PIN_RELAY = 4
PIN_CLED = 2

import grovepi
grovepi.pinMode(PIN_RELAY,"OUTPUT");
grovepi.pinMode(PIN_CLED,"OUTPUT")
grovepi.chainableRgbLed_init(PIN_CLED, 1)

def setColor(r,g,b):
    grovepi.storeColor(r,g,b)
    time.sleep(.1)
    grovepi.chainableRgbLed_pattern(PIN_CLED,0, 0)

# picoborg init
import PicoBorgRev
PBR = PicoBorgRev.PicoBorgRev()
PBR.Init()


class Program(MainLoop):
    def initialize(self):
        self.pad = gamepad.DS3Controller()

        self.emstop = False