PiGlow

This is a little fun add on from the Pimoroni gang www.pimoroni.com with 18 high brightness LEDs on it. [youtube=http://www.youtube.com/watch?v=1jJ349CX2IY]

To get an add-on like this to work on a Raspberry Pi (it uses what’s called the I2C protocol) you need to run a few little things using LX Terminal.

sudo apt-get install i2c-tools

and

sudo apt-get install python-smbus

and finally a little tool to enable the I2C pins to be used for this purpose

wget https://github.com/heeed/pi2c/raw/master/pi2c.sh

followed by

sudo bash pi2c.sh

Then once you’ve rebooted – come back here 🙂

Using PiGlow with ScratchGPIO

PiGlowAddonOnce you’ve added I2C support to your Raspberry Pi then just create a variable called AddOn and set it to PiGlow as the first line in your Green Flag event.

You can then create variables Led1 to Led18 and set them to values between 0 (for off) to 255 (Fully on). You can also have variables for Red,Orange,Yellow,Green,Blue and White to refer to each of the colours and the the same for Leg1, Leg2 and Leg3 (or Arm1..3 if you prefer to call them that)

PiGlowLegAs usual, you can use also use simple broadcasts instead of creating variables and say things like Broadcast Led1On to switch LED1 on

This script shows a how using the the join statement you can blink each leg in turn without having to use a lot of if statements.