How to use the Pi-LITEr from Ciseco

How To Use The Pi-LITEr From CisecoThe PiLITEr - Small, but full of potential

Controlling LEDs is one of the first projects people tend to shoot for, after the initial “Hello World” introduction to the Raspberry Pi. The problem with this is that not everyone is as good with the hardware side as they are with the code – with LEDs, resistors, current, volts etc putting these people off initially.

There’s also the difficulty for teachers trying to manage 20 children in a class, each soldering parts and/or getting things the wrong way round – a mammoth, and brave, task!

This is where small, pre-assembled and simplistic add-on boards such as the Pi-LITEr from Ciseco come in handy. Let me show you the board, and go through a few examples of simple code that I have written…

The Board

First of all – what is it?

The Pi-LITEr is a small add on board that pushes on to the Raspberry Pi’s GPIO pins. It comes with 8 LEDs, complete with the appropriate resistors, connected to 8 of the GPIO pins of your Pi.

It’s as simple as that – it’s the same as if you broke out your GPIO to a breadboard and wired up 8 LEDs yourself – albeit this is a much smaller, easier and tidier package.

No resistors, soldering or messing around. You simply place the order online, and the nice people at Ciseco send you the pre-assembled board. I think this is great as an educational tool, ticking all the boxes that educators need – Cheap, simple, easy and safe.

PiLITEr compared to a Lego brick

It’s the same size as an 8-point Lego brick!

What can I do with it?

This is the same as asking “What can I do with a Raspberry Pi and some LEDs” – depending on your level of Python skill, the possibilities really are endless.

The LEDs are connected to standard GPIO pins, so if you can define an ‘event’ that would set a GPIO pin to ‘output’ – then you can make it happen on the Pi-LITEr.

PiLITEr LEDs

The Pi-LITEr has 8 mega bright LEDs

Now some of us haven’t even got that far yet, and this is probably more focused towards new learners, so continue reading and we’ll cover some code examples…

Preparation

Hold on there my friend, your Pi might not be ready to use GPIO commands just yet. You may have these modules installed already, but there’s no harm in checking.

Get yourself into Terminal and run the following commands:

sudo apt-get update
sudo apt-get upgrade

(Updates your Raspberry Pi)

sudo apt-get install python-dev

(Gives our Pi everything it needs to use Python)

sudo apt-get install python-rpi.gpio

(Installs a module that enables you to control the GPIO pins)

Code Examples

There are 2 ways to control the Pi-LITEr that I know of – WiringPi and RPi.GPIO. I’ve always used the latter just because it’s the first method that I learnt when starting out, so I’ll use that in the code examples here (which we set up in the previous step).

I have added 5 code examples for try out and learn with your Pi-LITEr, in order of difficulty/complexity. Go ahead and play with the numbers…breaking is learning (my dad knows this from all the PCs I killed as a child).

Before you try, here’s a video showing how each one should work:

BEGINNER – Light LED 1 Only

If you’re just starting out, have a go at this first. It will show you how we assign a single GPIO pin to ‘turn on’ (LED 1):

#!/usr/bin/python
#
# PiLITEr 'beginner' script by the "Average Man"
# Check out http://AverageManVsRaspberryPi.com for more PiLITEr code examples

# Imports
import RPi.GPIO as GPIO
import time
import os

# Set the GPIO mode
GPIO.setmode(GPIO.BOARD)

# Turn off annoying warnings
GPIO.setwarnings(False)

# Define PiLITEr to GPIO mapping
LED1 = 7
LED2 = 11
LED3 = 13
LED4 = 12
LED5 = 15
LED6 = 16
LED7 = 18
LED8 = 22

# Main program
GPIO.setup(LED1, GPIO.OUT) #Set GPIO pin to output (to 'give' power)
GPIO.setup(LED2, GPIO.OUT) #Set GPIO pin to output (to 'give' power)
GPIO.setup(LED3, GPIO.OUT) #Set GPIO pin to output (to 'give' power)
GPIO.setup(LED4, GPIO.OUT) #Set GPIO pin to output (to 'give' power)
GPIO.setup(LED5, GPIO.OUT) #Set GPIO pin to output (to 'give' power)
GPIO.setup(LED6, GPIO.OUT) #Set GPIO pin to output (to 'give' power)
GPIO.setup(LED7, GPIO.OUT) #Set GPIO pin to output (to 'give' power)
GPIO.setup(LED8, GPIO.OUT) #Set GPIO pin to output (to 'give' power)

# Turn on LED 1
GPIO.output(LED1) == True

# Wait 5 seconds
time.sleep(5)

# Turn off LED 1
GPIO.output(LED1) == False

BASIC – Light LEDs 1, 2, 3 and 4

A step up from the last example – light the first 4 LEDs:

#!/usr/bin/python
#
# PiLITEr 'Basic' script by the "Average Man"
# Check out http://AverageManVsRaspberryPi.com for more PiLITEr code examples

# import
import RPi.GPIO as GPIO
import time
import os

# Set the GPIO mode
GPIO.setmode(GPIO.BOARD)

# Turn off annoying warnings
GPIO.setwarnings(False)

# Define PiLITEr to GPIO mapping
LED1 = 7
LED2 = 11
LED3 = 13
LED4 = 12
LED5 = 15
LED6 = 16
LED7 = 18
LED8 = 22

# Main program
GPIO.setup(LED1, GPIO.OUT) #Set GPIO pin to output (to 'give' power)
GPIO.setup(LED2, GPIO.OUT) #Set GPIO pin to output (to 'give' power)
GPIO.setup(LED3, GPIO.OUT) #Set GPIO pin to output (to 'give' power)
GPIO.setup(LED4, GPIO.OUT) #Set GPIO pin to output (to 'give' power)
GPIO.setup(LED5, GPIO.OUT) #Set GPIO pin to output (to 'give' power)
GPIO.setup(LED6, GPIO.OUT) #Set GPIO pin to output (to 'give' power)
GPIO.setup(LED7, GPIO.OUT) #Set GPIO pin to output (to 'give' power)
GPIO.setup(LED8, GPIO.OUT) #Set GPIO pin to output (to 'give' power)

# Turn on LEDs 1, 2, 3 and 4
while 1:
GPIO.output(LED1,GPIO.HIGH)
GPIO.output(LED2,GPIO.HIGH)
GPIO.output(LED3,GPIO.HIGH)
GPIO.output(LED4,GPIO.HIGH)

#Stay on for 6 seconds, then turn off LEDs and close
time.sleep(6)

GPIO.output(LED1,GPIO.LOW)
GPIO.output(LED2,GPIO.LOW)
GPIO.output(LED3,GPIO.LOW)
GPIO.output(LED4,GPIO.LOW)

SIMPLE – Light LEDs 1 to 8 In Turn

This time, we add timing to light one LED after an