RasPiO InsPiRing – Pac-Man Chase Light

Alex Eames of RasPi.TV designed and produced an excellent digital LED kit for micro board computers like the Raspberry Pi and Arduino called the RasPiO InsPiRing.

This controller and LED combination allows you to learn how to control digital LED’s like the popular “NeoPixel”. This uses similar LEDs to that of the NeoPixel based sets.

I backed the project on Kickstarter and put it together on the day it came through the post, but it then sat waiting for me to play with it.

Well – I have just done a quick script to have a yellow pixel go around the ring and eat white pixels. I was InsPiRed by Pac-Man.

The code for this is copied here, or you can clone my repo https://github.com/vwillcox/raspio-inspiring

from time import sleep     # RasPiO Inspiring scripts
import apa                 # http://rasp.io/inspiring
numleds = 24               # number of LEDs in our display
delay = 0.5                # seconds between frames
brightness = 1             # 0=OFF (224 or 0xE0), 31=FULL (255 or 0xFF)
ledstrip = apa.Apa(numleds)

#ledstrip.reset_leds()

#pacman(0,150,255)      # Yellow pacman
#food(255,255,255)      # food dots

def setpills(b,g,r):
    for led in range(numleds):
        ledstrip.led_set(led, brightness, b, g, r)
        ledstrip.write_leds()

def pacmove(b,g,r):
    for led in range(numleds):
        ledstrip.led_set(led, brightness, b, g, r)
        ledstrip.led_set(led-1, brightness, 0,0,0)
        if led == numleds-1:
            setpills(255,255,255)
        ledstrip.write_leds()
        sleep(delay)

setpills(255,255,255)
try:
    while True:
        pacmove(0,150,255)

finally:
    print("/nAll LEDs OFF - BYE!/n")
    ledstrip.reset_leds()