Example #1
0
def kill_mplayer():
    global color_rgb
    pid = 0
    
    ps_cmd = subprocess.Popen(
        ['ps', 'axw'],
        stdin=subprocess.PIPE,
        stdout=subprocess.PIPE,
        close_fds=True,
        shell=False
        )
    out = ps_cmd.communicate()[0]
    
    for line in out.splitlines():
        if ('mplayer' in line and 'AFN' in line) \
                or ('mplayer -novideo' in line) \
                or ('rtmpdump' in line):
            pid = int(line.split(None, 1)[0])
            if pid > 0:
                os.kill(pid, signal.SIGTERM)
    
    if pid > 0 and os.path.exists(mplayer_log):
        os.remove(mplayer_log)
    
    # Turn Chainable RGB LED off
    color_rgb = [0, 0, 0]
    grovepi.storeColor(color_rgb[0], color_rgb[1], color_rgb[2])
    grovepi.chainableRgbLed_pattern(rgbLEDPort, thisLedOnly, 0)
Example #2
0
def start_radio(channel, doPlay):
    global color_rgb
    
    # create lock file
    f = open(lock_file2, 'w')
    f.close()
    
    if doPlay == 1:
        kill_mplayer()
        
        if channel > 5:
            channel = 2
        #     radio_timer.start()
        # else:
        #     radio_timer.cancel()
        
        # Turn Chainable RGB LED on
        x = (channel * 21) / 100.0
        (r, g, b) = generate_rgb_color(x)
        color_rgb = [r, g, b]
        grovepi.storeColor(r, g, b)
        grovepi.chainableRgbLed_pattern(rgbLEDPort, thisLedOnly, 0)
        print('====> color: %d, %d, %d') % (r, g, b)
        
        # If not found mplayer, run mplayer.
        print('====> start Radio channel: %s.') % radioChannels[channel]
        if channel == 0:
            # Bad script. But anti zombie process.
            cmd = "nohup sh -c \"rtmpdump --live -r %s" \
              " | mplayer -novideo -af volnorm=2:%s - > /dev/null 2>&1\"" \
              " > /dev/null 2>&1 &" % (radioChannels[channel], vol_agqr)
            subprocess.call(cmd, shell=True)
        else:
            # Bad script. But anti zombie process.
            if channel == 1:
                cmd = "nohup mplayer -af volnorm=2:%s %s" \
                  " > /dev/null 2>&1 &" % (vol_tko, radioChannels[channel])
            else:
                cmd = "nohup mplayer -af volnorm=2:%s %s" \
                  " > /dev/null 2>&1 &" % (vol_norm, radioChannels[channel])
            subprocess.call(cmd, shell=True)
            # subprocess.Popen(
            #     cmd.split(),
            #     stdout=open('/dev/null', 'w'),
            #     stderr=open(mplayer_log, 'a'),
            #     preexec_fn=os.setpgrp
            #     )
    else:
        print('====> stop Radio')
        kill_mplayer()
    
    # Remove lock file.
    os.remove(lock_file2)
    
    # Turn feedback LED off
    grovepi.digitalWrite(feedbackLEDPort, 0)
Example #3
0
def return_color():
    global color_rgb
    
    # Turn LED off
    grovepi.digitalWrite(feedbackLEDPort, 0)

    # Turn RGB LED off
    grovepi.storeColor(color_rgb[0], color_rgb[1], color_rgb[2])
    grovepi.chainableRgbLed_pattern(rgbLEDPort, thisLedOnly, 0)

    # Remove lock file.
    os.remove(lock_file3)
Example #4
0
 def change_light(self, isOn):
     """
     Switch the light ON or OFF.
     """
     try:
         import grovepi
     except ImportError:
         return
     if isOn:
         grovepi.chainableRgbLed_pattern(self.led_pin, 0, 0)
         self.led_is_on = True
     else:
         grovepi.chainableRgbLed_test(self.led_pin, self.nb_leds, 0)
         self.led_is_on = False
Example #5
0
    def setColor(self, color):
        thisLedOnly = 0
        if color == 0:
            grovepi.storeColor(0, 0, 255)  #blue
            print("set: p" + str(self.pin) + " to blue")

        elif color == 1:
            grovepi.storeColor(0, 255, 0)  #green
            print("set: p" + str(self.pin) + " to greens")
        elif color == 2:
            grovepi.storeColor(255, 0, 0)  #red
            print("set: p" + str(self.pin) + " to red")
        elif color == -1:
            grovepi.storeColor(0, 0, 0)  #off
            print("set: p" + str(self.pin) + " to off")
        else:
            grovepi.storeColor(255, 255, 255)
            print("set: p" + str(self.pin) + " to default white")
        grovepi.chainableRgbLed_pattern(self.pin, thisLedOnly, 0)
Example #6
0
def turn_on_led(led_num,r,g,b):
    grovepi.storeColor(r,g,b)
    time.sleep(.1)
    grovepi.chainableRgbLed_pattern(pin, thisLedOnly, led_num)
    time.sleep(.1)
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
    grovepi.chainableRgbLed_pattern(pin, thisLedOnly, 9)
    time.sleep(.5)

    # pause so you can see what happened
    time.sleep(2)

    # reset (all off)
    grovepi.chainableRgbLed_test(pin, numleds, testColorBlack)
Example #8
0
    
    # 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()
    
    if encoder_val == 0:
        color_rgb = [0, 0, 0]
    else:
        color_rgb = [255, 0, 0]

    grovepi.storeColor(color_rgb[0], color_rgb[1], color_rgb[2])
    grovepi.chainableRgbLed_pattern(rgbLEDPort, thisLedOnly, 0)
    
    # recieve SIGTERM
    signal.signal(signal.SIGTERM, signal_term_handler)
    
    while True:
        try:
            # Encoder
            if radio_on == 1:
                [new_val, encoder_val] = grovepi.encoderRead()
                if new_val:
                    print('====> Encoder: %d') % encoder_val
                    if os.path.exists(lock_file2):
                        print('====> Locking...')
                    else:
                        start_radio(encoder_val, radio_on)
Example #9
0
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
    grovepi.chainableRgbLed_pattern(pin, thisLedOnly, 9)
    time.sleep(.5)

    # pause so you can see what happened
    time.sleep(2)

    # reset (all off)
    grovepi.chainableRgbLed_test(pin, numleds, testColorBlack)
Example #10
0
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
    grovepi.chainableRgbLed_pattern(pin, thisLedOnly, 9)
    time.sleep(.5)

    # pause so you can see what happened
    time.sleep(2)

    # reset (all off)
    grovepi.chainableRgbLed_test(pin, numleds, testColorBlack)
Example #11
0
 def notify(self, data):
     super(GroveChainableRgbLedObserver, self).notify(data)
     rgb = self.get_level_color(self.get_highest_level(self.latest))
     grovepi.chainableRgbLed_pattern(self.pin, 0, 0)
     grovepi.storeColor(*rgb)
Example #12
0
def chained_led():
    try:

        # 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)

        # reset (all off)
        grovepi.chainableRgbLed_test(pin, numleds, testColorBlack)
        time.sleep(.5)

        print("Test 2b) Test Patterns - blue")

        # test pattern 1 blue
        grovepi.chainableRgbLed_test(pin, numleds, testColorBlue)
        time.sleep(1)

        print("Test 2c) Test Patterns - green")

        # test pattern 2 green
        grovepi.chainableRgbLed_test(pin, numleds, testColorGreen)
        time.sleep(1)

        print("Test 2d) Test Patterns - cyan")

        # test pattern 3 cyan
        grovepi.chainableRgbLed_test(pin, numleds, testColorCyan)
        time.sleep(1)

        print("Test 2e) Test Patterns - red")

        # test pattern 4 red
        grovepi.chainableRgbLed_test(pin, numleds, testColorRed)
        time.sleep(1)

        print("Test 2f) Test Patterns - magenta")

        # test pattern 5 magenta
        grovepi.chainableRgbLed_test(pin, numleds, testColorMagenta)
        time.sleep(1)

        print("Test 2g) Test Patterns - yellow")

        # test pattern 6 yellow
        grovepi.chainableRgbLed_test(pin, numleds, testColorYellow)
        time.sleep(1)

        print("Test 2h) Test Patterns - white")

        # test pattern 7 white
        grovepi.chainableRgbLed_test(pin, numleds, testColorWhite)
        time.sleep(1)

        # pause so you can see what happened
        time.sleep(2)

        # reset (all off)
        grovepi.chainableRgbLed_test(pin, numleds, testColorBlack)
        time.sleep(.5)

        print("Test 3a) Set using pattern - this led only")

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

        # set led 3 to red
        grovepi.chainableRgbLed_pattern(pin, thisLedOnly, 2)
        time.sleep(.5)

        # pause so you can see what happened
        time.sleep(2)

        # reset (all off)
        grovepi.chainableRgbLed_test(pin, numleds, testColorBlack)
        time.sleep(.5)

        print("Test 3b) Set using pattern - all leds except this")

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

        # set all leds except for 3 to blue
        grovepi.chainableRgbLed_pattern(pin, allLedsExceptThis, 3)
        time.sleep(.5)

        # pause so you can see what happened
        time.sleep(2)

        # reset (all off)
        grovepi.chainableRgbLed_test(pin, numleds, testColorBlack)
        time.sleep(.5)

        print("Test 3c) Set using pattern - this led and inwards")

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

        # set leds 1-3 to green
        grovepi.chainableRgbLed_pattern(pin, thisLedAndInwards, 2)
        time.sleep(.5)

        # pause so you can see what happened
        time.sleep(2)

        # reset (all off)
        grovepi.chainableRgbLed_test(pin, numleds, testColorBlack)
        time.sleep(.5)

        print("Test 3d) Set using pattern - this led and outwards")

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

        # set leds 7-10 to green
        grovepi.chainableRgbLed_pattern(pin, thisLedAndOutwards, 6)
        time.sleep(.5)

        # pause so you can see what happened
        time.sleep(2)

        # reset (all off)
        grovepi.chainableRgbLed_test(pin, numleds, testColorBlack)
        time.sleep(.5)

        print("Test 4a) Set using modulo - all leds")

        # change color to black (fully off)
        grovepi.storeColor(0, 0, 0)
        time.sleep(.5)

        # set all leds black
        # offset 0 means start at first led
        # divisor 1 means every led
        grovepi.chainableRgbLed_modulo(pin, 0, 1)
        time.sleep(.5)

        # change color to white (fully on)
        grovepi.storeColor(255, 255, 255)
        time.sleep(.5)

        # set all leds white
        grovepi.chainableRgbLed_modulo(pin, 0, 1)
        time.sleep(.5)

        # pause so you can see what happened
        time.sleep(2)

        # reset (all off)
        grovepi.chainableRgbLed_test(pin, numleds, testColorBlack)
        time.sleep(.5)

        print("Test 4b) Set using modulo - every 2")

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

        # set every 2nd led to red
        grovepi.chainableRgbLed_modulo(pin, 0, 2)
        time.sleep(.5)

        # pause so you can see what happened
        time.sleep(2)

        print("Test 4c) Set using modulo - every 2, offset 1")

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

        # set every 2nd led to green, offset 1
        grovepi.chainableRgbLed_modulo(pin, 1, 2)
        time.sleep(.5)

        # pause so you can see what happened
        time.sleep(2)

        # reset (all off)
        grovepi.chainableRgbLed_test(pin, numleds, testColorBlack)
        time.sleep(.5)

        print("Test 4d) Set using modulo - every 3, offset 0")

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

        # set every 3nd led to red
        grovepi.chainableRgbLed_modulo(pin, 0, 3)
        time.sleep(.5)

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

        # set every 3nd led to green, offset 1
        grovepi.chainableRgbLed_modulo(pin, 1, 3)
        time.sleep(.5)

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

        # set every 3nd led to blue, offset 2
        grovepi.chainableRgbLed_modulo(pin, 2, 3)
        time.sleep(.5)

        # pause so you can see what happened
        time.sleep(2)

        # reset (all off)
        grovepi.chainableRgbLed_test(pin, numleds, testColorBlack)
        time.sleep(.5)

        print("Test 4e) Set using modulo - every 3, offset 1")

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

        # set every 4nd led to yellow
        grovepi.chainableRgbLed_modulo(pin, 1, 3)
        time.sleep(.5)

        # pause so you can see what happened
        time.sleep(2)

        print("Test 4f) Set using modulo - every 3, offset 2")

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

        # set every 4nd led to magenta
        grovepi.chainableRgbLed_modulo(pin, 2, 3)
        time.sleep(.5)

        # pause so you can see what happened
        time.sleep(2)

        # reset (all off)
        grovepi.chainableRgbLed_test(pin, numleds, testColorBlack)
        time.sleep(.5)

        print("Test 5a) Set level 6")

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

        # set leds 1-6 to green
        grovepi.write_i2c_block(0x04, [95, pin, 6, 0])
        time.sleep(.5)

        # pause so you can see what happened
        time.sleep(2)

        # reset (all off)
        grovepi.chainableRgbLed_test(pin, numleds, testColorBlack)
        time.sleep(.5)

        print("Test 5b) Set level 7 - reverse")

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

        # set leds 4-10 to red
        grovepi.write_i2c_block(0x04, [95, pin, 7, 1])
        time.sleep(.5)

    except KeyboardInterrupt:
        # reset (all off)
        grovepi.chainableRgbLed_test(pin, numleds, testColorBlack)
    except IOError:
        print("Error")
Example #13
0
def RGB(rouge, vert, bleu):
    grovepi.storeColor(rouge, vert, bleu)
    grovepi.chainableRgbLed_pattern(RGB_pin, 2, 5)
Example #14
0
def setColor(r,g,b):
    grovepi.storeColor(r,g,b)
    time.sleep(.1)
    grovepi.chainableRgbLed_pattern(PIN_CLED,0, 0)
Example #15
0
def turn_off_led(led_num):
    grovepi.storeColor(0,0,0)
    time.sleep(.1)
    grovepi.chainableRgbLed_pattern(pin, thisLedOnly, led_num)
    time.sleep(.1)
Example #16
0
def turn_on_led(led_num,r,g,b):
    grovepi.storeColor(r,g,b)
    time.sleep(.1)
    grovepi.chainableRgbLed_pattern(pin, thisLedOnly, led_num)
    time.sleep(.1)
Example #17
0
def turn_off_led(led_num):
    grovepi.storeColor(0,0,0)
    time.sleep(.1)
    grovepi.chainableRgbLed_pattern(pin, thisLedOnly, led_num)
    time.sleep(.1)
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
    grovepi.chainableRgbLed_pattern(pin, thisLedOnly, 9)
    time.sleep(.5)

    # pause so you can see what happened
    time.sleep(2)

    # reset (all off)
    grovepi.chainableRgbLed_test(pin, numleds, testColorBlack)
Example #19
0
def chained_led():
	try:

		# 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)

		# reset (all off)
		grovepi.chainableRgbLed_test(pin, numleds, testColorBlack)
		time.sleep(.5)

		print ("Test 2b) Test Patterns - blue")

		# test pattern 1 blue
		grovepi.chainableRgbLed_test(pin, numleds, testColorBlue)
		time.sleep(1)

		print ("Test 2c) Test Patterns - green")

		# test pattern 2 green
		grovepi.chainableRgbLed_test(pin, numleds, testColorGreen)
		time.sleep(1)


		print ("Test 2d) Test Patterns - cyan")

		# test pattern 3 cyan
		grovepi.chainableRgbLed_test(pin, numleds, testColorCyan)
		time.sleep(1)


		print ("Test 2e) Test Patterns - red")

		# test pattern 4 red
		grovepi.chainableRgbLed_test(pin, numleds, testColorRed)
		time.sleep(1)


		print ("Test 2f) Test Patterns - magenta")

		# test pattern 5 magenta
		grovepi.chainableRgbLed_test(pin, numleds, testColorMagenta)
		time.sleep(1)


		print ("Test 2g) Test Patterns - yellow")

		# test pattern 6 yellow
		grovepi.chainableRgbLed_test(pin, numleds, testColorYellow)
		time.sleep(1)


		print ("Test 2h) Test Patterns - white")

		# test pattern 7 white
		grovepi.chainableRgbLed_test(pin, numleds, testColorWhite)
		time.sleep(1)


		# pause so you can see what happened
		time.sleep(2)

		# reset (all off)
		grovepi.chainableRgbLed_test(pin, numleds, testColorBlack)
		time.sleep(.5)


		print ("Test 3a) Set using pattern - this led only")

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

		# set led 3 to red
		grovepi.chainableRgbLed_pattern(pin, thisLedOnly, 2)
		time.sleep(.5)

		# pause so you can see what happened
		time.sleep(2)

		# reset (all off)
		grovepi.chainableRgbLed_test(pin, numleds, testColorBlack)
		time.sleep(.5)


		print ("Test 3b) Set using pattern - all leds except this")

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

		# set all leds except for 3 to blue
		grovepi.chainableRgbLed_pattern(pin, allLedsExceptThis, 3)
		time.sleep(.5)

		# pause so you can see what happened
		time.sleep(2)

		# reset (all off)
		grovepi.chainableRgbLed_test(pin, numleds, testColorBlack)
		time.sleep(.5)


		print ("Test 3c) Set using pattern - this led and inwards")

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

		# set leds 1-3 to green
		grovepi.chainableRgbLed_pattern(pin, thisLedAndInwards, 2)
		time.sleep(.5)

		# pause so you can see what happened
		time.sleep(2)

		# reset (all off)
		grovepi.chainableRgbLed_test(pin, numleds, testColorBlack)
		time.sleep(.5)


		print ("Test 3d) Set using pattern - this led and outwards")

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

		# set leds 7-10 to green
		grovepi.chainableRgbLed_pattern(pin, thisLedAndOutwards, 6)
		time.sleep(.5)

		# pause so you can see what happened
		time.sleep(2)

		# reset (all off)
		grovepi.chainableRgbLed_test(pin, numleds, testColorBlack)
		time.sleep(.5)


		print ("Test 4a) Set using modulo - all leds")

		# change color to black (fully off)
		grovepi.storeColor(0,0,0)
		time.sleep(.5)

		# set all leds black
		# offset 0 means start at first led
		# divisor 1 means every led
		grovepi.chainableRgbLed_modulo(pin, 0, 1)
		time.sleep(.5)

		# change color to white (fully on)
		grovepi.storeColor(255,255,255)
		time.sleep(.5)

		# set all leds white
		grovepi.chainableRgbLed_modulo(pin, 0, 1)
		time.sleep(.5)

		# pause so you can see what happened
		time.sleep(2)

		# reset (all off)
		grovepi.chainableRgbLed_test(pin, numleds, testColorBlack)
		time.sleep(.5)


		print ("Test 4b) Set using modulo - every 2")

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

		# set every 2nd led to red
		grovepi.chainableRgbLed_modulo(pin, 0, 2)
		time.sleep(.5)

		# pause so you can see what happened
		time.sleep(2)


		print ("Test 4c) Set using modulo - every 2, offset 1")

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

		# set every 2nd led to green, offset 1
		grovepi.chainableRgbLed_modulo(pin, 1, 2)
		time.sleep(.5)

		# pause so you can see what happened
		time.sleep(2)

		# reset (all off)
		grovepi.chainableRgbLed_test(pin, numleds, testColorBlack)
		time.sleep(.5)


		print ("Test 4d) Set using modulo - every 3, offset 0")

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

		# set every 3nd led to red
		grovepi.chainableRgbLed_modulo(pin, 0, 3)
		time.sleep(.5)

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

		# set every 3nd led to green, offset 1
		grovepi.chainableRgbLed_modulo(pin, 1, 3)
		time.sleep(.5)

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

		# set every 3nd led to blue, offset 2
		grovepi.chainableRgbLed_modulo(pin, 2, 3)
		time.sleep(.5)

		# pause so you can see what happened
		time.sleep(2)

		# reset (all off)
		grovepi.chainableRgbLed_test(pin, numleds, testColorBlack)
		time.sleep(.5)


		print ("Test 4e) Set using modulo - every 3, offset 1")

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

		# set every 4nd led to yellow
		grovepi.chainableRgbLed_modulo(pin, 1, 3)
		time.sleep(.5)

		# pause so you can see what happened
		time.sleep(2)


		print ("Test 4f) Set using modulo - every 3, offset 2")

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

		# set every 4nd led to magenta
		grovepi.chainableRgbLed_modulo(pin, 2, 3)
		time.sleep(.5)

		# pause so you can see what happened
		time.sleep(2)

		# reset (all off)
		grovepi.chainableRgbLed_test(pin, numleds, testColorBlack)
		time.sleep(.5)


		print ("Test 5a) Set level 6")

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

		# set leds 1-6 to green
		grovepi.write_i2c_block(0x04,[95,pin,6,0])
		time.sleep(.5)

		# pause so you can see what happened
		time.sleep(2)

		# reset (all off)
		grovepi.chainableRgbLed_test(pin, numleds, testColorBlack)
		time.sleep(.5)


		print ("Test 5b) Set level 7 - reverse")

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

		# set leds 4-10 to red
		grovepi.write_i2c_block(0x04,[95,pin,7,1])
		time.sleep(.5)


	except KeyboardInterrupt:
		# reset (all off)
		grovepi.chainableRgbLed_test(pin, numleds, testColorBlack)
	except IOError:
		print ("Error")