Using a Raspberry PI to control an extreme feedback device


In this article I will show you how to use a Raspberry PI and a Jenkins CI server to control a USB traffic light. I have used the USB traffic light in software projects to display the status of one or multiple Jenkins CI jobs. The traffic light was clearly visible to all team members and stakeholders and everybody knew right away once a build was broken.


Unfortunately I did not find an affordable USB traffic light, that I could control directly from the Jenkins CI server over the network and that came with software for different operating systems. I was also forced to have it connected to my local computer. Once I left the office and the computer was shut down, the traffic light was turned off.

That problem can be solved using the inexpensive Raspberry PI 🙂


The following diagram gives an overview of the architecture:

  1. We will have a script running on the Raspberry PI that constantely polls the status of a configured Jenkins Job
  2. Depending on the status of the Jenkins Job the script updates the USB traffic light



And these are the Prerequisites

Lets go 🙂

Raspberry PI installation

First of all we need to get the Raspberry up and running. Therefore you need to install a bootloader and operating system image on the SD Card. I suggest you use the Raspbian “wheezy” installation.

I was running the installation from my ubuntu computer. When you are using Windows or Mac please check for information.

Step 1: Download the wheezy image

Step 2: Verify and unzip image

marcelbirkner@ubuntu:~/Downloads/raspberry$ sha1sum
marcelbirkner@ubuntu:~/Downloads/raspberry$ unzip

Step 3: Prepare the SD Card

Insert the SD Card into your computer, in order to copy the wheezy image onto the card.

marcelbirkner@ubuntu:~/Downloads$ df -h
Filesystem Size Used Avail Use% Mounted on
/dev/mmcblk0p1 1.9G 1.8G 75M 97% /media/marcelbirkner/SD_CARD
marcelbirkner@ubuntu:~/Downloads$ umount /dev/mmcblk0p1

Step 4: Copy image to SD Card

sudo dd bs=4M if=2013-02-09-wheezy-raspbian.img of=/dev/mmcblk0

Step 5: Prepare Raspberry PI hardware

Once you have copied the wheezy image onto the SD Card you can connect the card to your Raspberry. Add the network cable, tv cable, USB keyboard, your monitor and the Cleware USB traffic light to the Raspberry. After that you can attach the micro USB power supply to startup your Pi.

You should see a blue screen starting up the system. Please follow the instructions on the screen. During the first startup the Raspberry wants to connect to the internet and check for updates. Once you are done you can proceed with the next step.

Step 6: Login to your Raspberry PI

ssh pi@
Password: raspberry

Once you are logged in you can check out the operating system and directory structure. Next you should switch to the root user.

sudo su

Step 7: Install Clewarecontrol

During the next step we need to install additional software that controls the USB traffic light under Linux. This Software is provided by Folkert van Heusden.

tar xvfz clewarecontrol-2.5.tgz
cd clewarecontrol-2.5
make install

Step 8: Test USB traffic light

First verify that you can find your USB traffic light. It should return the device id. You can use that id later on to control specific traffic lights, in case you have multiple attached to your Raspberry PI.

root@raspberrypi:~/clewarecontrol-2.5# clewarecontrol -l
Cleware library version: 330
Number of Cleware devices found: 1
Device: 0, type: Switch1 (8), version: 29, serial number: 900455

In case the device list is empty you should reboot the raspberry.

sudo reboot

Once the software is installed correctly ou should be able to control the red, yellow and green light:

root@raspberrypi:~/clewarecontrol-2.5# clewarecontrol -d 900455 -as 2 1
Switch 2: set to On

Step 9: Connect Jenkins Build Job and USB Traffic light

In the last step we need to configure a script that checks the status of a Jenkins CI Job. You can use the following shell script for that. Just fill out your properties on top of the script and start it on the Raspberry PI command line.

# This script is used to control a USB Traffic Light from Cleware. You can buy 
# the USB Traffic Light from this shop:
# The script uses the REST API and can be used for newer versions of Jenkins that provide a REST API.
# Requirements:
#   The Cleware USB Traffic Light comes with a control software that you can 
#   download from 
#   This script can be run under Linux. You need to have "curl" installed, 
#   so the script can poll the REST API.
#   This script has been tested under Ubuntu and clewarecontrol 2.0
# @MarcelBirkner
# Methods for controlling the device (2=blue, 1=yellow, 0=red)
lightOn() {
  clewarecontrol -c 1 -b -d $DEVICE_NO -as $1 1 2>&1 
lightOff() {
  clewarecontrol -c 1 -b -d $DEVICE_NO -as $1 0 2>&1 
allOff() {
  lightOff 0;
  lightOff 1;
  lightOff 2;
while true; do 
  color=`curl -silent -u $USER:$PASSWORD $JENKINS_SERVER$JOB_NAME/api/json?pretty=true | grep color `
  state=`echo $color | sed 's/\"//g' | sed 's/,//g' | awk '{print $3}'` 
  echo $state;  
  case $state in 
    red)          echo "State: $state"; allOff; lightOn 0;;
    yellow)       echo "State: $state"; allOff; lightOn 1;;
    blue)         echo "State: $state"; allOff; lightOn 2;;
    red_anime)    echo "State: $state"; allOff; sleep 1; lightOn 0; sleep 1; lightOff 0; sleep 1; lightOn 0;;
    yellow_anime) echo "State: $state"; allOff; sleep 1; lightOn 1; sleep 1; lightOff 1; sleep 1; lightOn 1;;
    blue_anime)   echo "State: $state"; allOff; sleep 1; lightOn 2; sleep 1; lightOff 2; sleep 1; lightOn 2;;
    *)            echo "Nothing matched state: $state";;  
  sleep 1;  

I posted the script as a Gist on Github so you do not have to manually create the script on your PI. Link:

Simply follow these instructions:

wget -o gist.tgz
tar xvfz gist.tgz
cd gist6037722*
chmod u+x

In the next step you need to configure the shell script that checks your Jenkins job status and controls the usb traffic light.

  • set USER
  • set PASSWORD
  • set JOB_NAME
  • set DEVICE_NO

Once you have configured these parameters on top of the shell script you can start the script. It should poll your jenkins and update the traffic lights.

Start the configured jenkins job and see what happens 🙂

You can find more sample script for bash, ruby and clojure on the following site:

The Final Result

Here are some pictures and a video what my setup looks like. For the video I configured a Jenkins job that has a select box. Depending on the selected value (success, failure) the build job will fail or succeed.

2013-07-20 14.41.052013-07-20 14.05.59jenkins-screenshot

Video showing the Raspberry PI, an example Jenkins Job and the Cleware USB traffic light.

Watch video: Raspberry PI controlling usb traffic light

Have fun with your new extreme feedback device and feel free to share your ideas and experiences 🙂


  • Bernd Zuther

    I have written a java driver for the cleware traffic light. Perhaps you can help me testing it.

  • Marcel Birkner

    16. August 2013 von Marcel Birkner

    Hi Bernd,
    can I find the code somewhere on github? I am curious to see how you implemented the driver with Java.

  • Fiona

    16. May 2014 von Fiona


    am new to coding and this looks amazing, i have the traffic light and i added the script shell to my terminal and was getting ” Motion not detected” and “-b is not recognised”.

    I was executing this on our local jenkins’s box, is there anything that am not doing right. Or do I need to add a java code within my scripts that will be able to trigger the traffic light.

    I do need your assistance please.

  • Marcel Birkner

    20. May 2014 von Marcel Birkner

    Hi Fiona,

    can you control the traffic light from your command line via clewarecontrol? All you need to have running is clewarecontrl

    Try the following:

    clewarecontrol -c 1 -as 0 1
    clewarecontrol -c 1 -as 0 0

    What is the result?



Your email address will not be published.