Next project
Outreach Initiatives and Community Awareness


Impress Your Friends & Family at Christmas: Control Decorative Lighting Using Webbrowsers

Video Demonstration

Working video demo of "Decorative Lighting Controller" using LED sequence:

Objective

This project permits you control over a sequence of Christmas Lights, for instance a string or sequence of LEDs. You will use a Raspberry Pi to implement control. Alter the blinking sequence opening the webpage DIY taught in this lab manual. Once loaded a web browser, by you can enter the sequence of blinks for desired duration in seconds. For example: 120 blinks in 60 seconds, or 20 blinks in 8 seconds.

By doing this project, you and your student will learn about physical computing with the PiFace Digital. It is a interfacing and breakout board for the Raspberry Pi. It finds use in computers that help implement decisions on physical objects, like lights. Raspberry PiFace Digital allows all this to happen through computer-dependent convenient architectures of communication:

  • Internet Networking
  • Many Sensor Networking
  • High Speed Decision Making
  • Visual User Interfaces

The Raspberry Pi was chosen as the embedded computer for this application since is:

  1. Inexpensive
  2. Consumes low power
  3. Can Network
  4. Visually Show on Screen
  5. Supported by Online Help Community
  6. Compatible to Execute All Programming Languages

Remember, that the Microcontroller Arduino was limited to C programming language only. In contrast, Raspberry Pi Microcomputer is unlimited in scope of languages. It supports Java, C++, C, C#, C Objective, Scratch, JavaScript, Python - even LISP, Cobol, Fortran!

Its architecture of a computer and not microcontroller endows it boadest applicability in embedded computing applications.An advantage of the Raspberry Pi is that it is capable of interfacing with the PiFace breakout board. The PiFace is what allows the Raspberry Pi to "talk" to the real world. Through software running on the Raspberry Pi, input pins can be read and output pins can be switched on and off. It even has relays for controlling high current loads. All the software included in this project is written in Python. This language was chosen because it is friendly and less obscure syntax with high usability. Python has libraries that handle the HTTP requests as well as libraries that allow easy control of the PiFace.

Description

The project begins with an simple HTTP server written in Python running on the Raspberry Pi. Once connected to a network, a user loads it's web page pointing their browser to xxx.xxx.xxx.xxx:9000 where xxx.xxx.xxx.xxx is the IP address of the Raspberry Pi. The user is then presented with a screen where they enter the blinking sequence, in ones and zeros as well as how long each element of the sequence lasts. Once the user clicks "Submit" a POST request is sent to the HTTP server on the Raspberry Pi. A separate thread runs switching on and off the lights as directed by the information sent from the web browser.

This project is useful for controlling large displays of Christmas lights. As IPv4 has 32 bit long addresses, a network could handle and many as 232 (4294967296) Raspberry Pi based controllers.

Once the student completes this lab, they will have learned about computer networking, web development and physical computing. They will learn about computer networking by assigning a static IP address to the Raspberry Pi and they will learn about web development when working with the user interface for the controller. This project provides an example of physical computing as the student controls real world events with software and computer hardware.

Materials List

ItemQuantity
Raspberry Pi that is able to access a Local Area Network (LAN)1
PiFace breakout board for Raspberry Pi1
LED6
100 Ω resistors3
Jumper wiresabout 8
Solderless breadboard1
AA batteries6
(Optional) AA Battery holder *1
Ethernet cable1
Raspberry Pi power supply1

* If holder is not there, just serially connect the batteries in base to tip repetition. Solder the jumpire wires. This will give you 6 times the power of each AA battery, which is 6 * 1.5 V = 9.0 V to power the circuit.

Software Tools

Skills

Ability to control the Raspberry Pi, either a computer with an SSH connection or a monitor and keyboard.

Method

  1. Setup the PiFace.

    1. Carefully connect the PiFace to the Raspberry Pi, by connecting the Pi's male GPIO header to the PiFace's female GPIO header.

    2. Setup the SPI kernel module on the Raspberry Pi

      1. In a terminal on the Raspberry Pi, type: cd /etc/modprobe.d

      2. Then type: sudo nano raspi-blacklist.conf

      3. Comment out the line "blacklist spi-bcm2708" by changing it to "#blacklist spi-bcm2708"

      4. Press Ctrl+O to save the file.

      5. Reboot the Raspberry Pi.

      6. Under /dev you should see spidev0.0 and spidev0.1

    3. Make the sequence of Christmas Lights according to schematic in Figure 1.

      Figure 2 shows you one possible way of wiring together the circuit on a breadboard.
    4. Figure 1 Circuit diagram or schematic of LED string that makes a short segment of a possibly larger Chrismtas Decorative Lighting.

      Figure 2 Bread board view once the Christmas LED Lights are completed in wiring arangement according to schematic.

    5. Install Python libraries on the Raspberry Pi

      1. Download the following file: https://github.com/thomasmacpherson/piface/archive/master.zip

      2. Extract the .zip file and enter the pifacedigitalio-master directory.

      3. Run the following command: sudo python setup.py install. This will install the pifacedigitalio python library. Install any dependencies if they are needed along the way.

      4. To see if this worked, open a python shell by typing "python" in the command line. Run the following commands.

        • import pifacedigitalio as pfio

        • pfio.init()

        • pfio.digital_write(2,1)

LED 2 should now be ON

  • pfio.digital_write(2,0)

LED 2 should now be OFF

  • exit()

  • Setup the networking

    1. On the Raspberry Pi go to /etc/network and edit interfaces as root.

    2. Delete the line iface eth0 inet dhcp and add the following lines:

    • iface eth0 inet static

    • address 192.168.1.5

    • netmask 255.255.255.0

    • gateway 192.168.1.4

  • We have just given the Raspberry Pi a static IP address of192.168.1.5

  • Connect the Raspberry Pi to your computer with an Ethernet cable and run the following command on your computer: sudo ifconfig eth0 192.168.1.4

  • We have just given the Ethernet interface on our computer the IP address 192.168.1.4

  • On the computer open a terminal and type ping 192.168.1.5 . If information returns, everything is working.

  • Setup the HTTP server on the Raspberry Pi

    1. Copy the directory RPi_sequence to the Raspberry Pi

    2. Open the file webserver.py and modify the variable index_file_path to point to the file index.html (absolute reference)

    3. On the Raspberry Pi's console, in the Rpi_sequence directory type the following command: python webserver.py . The HTTP server is now up and running.

    4. Test the server by pointing the browser on your computer to http://192.168.1.5:9000 and verify that LED 0 on the Raspberry Pi blinks according to the sequence.

  • Build the Christmas lights by following the schematic.

      1. Connect the Christmas lights to the PiFace. The two wires should be inserted into the two terminals that are closest to the GPIO header on the terminal block that is closest to the GPIO header. Order of insertion does not matter.

      2. Make the HTTP server start automatically on boot.

        1. On the Raspberry Pi, enter the command crontab -e and add the following line:

          @reboot /home/pi/Desktop/PiFace/seq_web_interface/webserver.py

        2. Save the crontab and reboot

    Figure 3 Raspberry PiFace Digital is connected on top of Raspberry Pi (the board bellow, with yellow port). The Christmas LEDs are powerd from the connected terminals shown here.

    Areas for improvement:

    This lab teaches students the basics of physical computing, computer networking and web development. With more advanced knowledge in these areas the student can make modifications such as:


    • Making the user have to type a password in order to access the control page.

    • Port forwarding so that the control interface can be accessed anywhere that there is an Internet connection.

    • Give more precise control to the LEDs on the Christmas lights so that individual LEDs and be switched on and off.

    Further Readings

    To have a deepened knowledge in Electronics, Networking and Software Uses in Entertainment, you should first gain a "knowledge scaffold and learning directions" of powerful math, science, computer technologies and engineering. Address gaps in your foundation or gain new expertise as a student or teacher from free schools:

    Once you feel confident, please Search with keywords "Animatronics", "Entertainment Technologies", "Controls in Lighting, Show, Stage", at UOIT Library or Open Textbooks and Open Encyclopediae:

  • Other Projects
    Networked Thermometer
Networked Thermometer Thermometers are old. They are useful: superb tool to control experiments in science labs, monitor body heat, get weather data, save devices from overheating as your flat screen tv, and car engines. Continue >>
    Arduino Lilypad Remote Mouse
Arduino Lilypad Remote Mouse Control your computer's mouse with this homemade remote-control. Build touch switches completely in software and then link the remote to the computer via infrared. Continue >>
    Optical Network Made Easy
Optical Network Made Easy Optical communication is fast, cheap, and reliable. Build your own prototype of a peer-to-peer network using laser. Understand how big Rogers, Bell and use Fibre to connect you in lightning speed to... Continue >>
    Paper Music Player Tutorial
Paper Music Player Tutorial Play music from paper as if the paper was an "ipod". You build a system that senses capacitive touch on pencil shaded shapes on paper. With these touches music is controlled. Continue >>
    Professional Circuit Drafting
Professional Circuit Drafting CAD drawing gives you professional grade circuit schematics and prototype models. Learn to communicate design of electronics and hardware innovation like the professional engineer. Continue >>
    Knock to Ring Bell
Knock to Ring Bell Make a complete musical bell system that rings with your knock. Possibly, this may reduce door banging or frustration at dormitory doors that aren't allowed to have buttoned door bells, yikes! Continue >>
    Raspberry Pi Tweet to my Door Raspberry Pi Tweet to my Door Raspberry Pi connected to colour display wirelessly. Show your twitter updates on a screen attached to your door at school's club office, classroom, treehouse room. Display to your audience your... Continue >>
    Gesture Pong Game
Gesture Pong Game Build your own motion tracked game and console similar to Kinect or Wii. Inside is code and design helping you make the classic Pong Game. Play the game as you move on your tv or monitor. See step by... Continue >>
    Self-Driving Car
Self-Driving Car Robots are smart. Here you transform your old toy car or another vehicle into a bot that follows a wavy line. Use it for shipping goods between unmanned travel ports. Real world uses are endless. Continue >>
    Broadcast Your Radio
Broadcast Your Radio Broadcast your music and voice wirelessly. Spread your news with your friends over short distance using radio. It is easy to make, free, and won't get CRT angry at you. Radio podcasts, chatroom uses... Continue >>
    Pedometer for Athletes
Pedometer for Athletes Supercharge your shoe! Use it to find issues in your run during basketball, track or soccer. Or, track the distance and stats of your jog. Help keep others keep their walk at constant pace, such as... Continue >>
    Arduino Tweets to my Door Arduino Tweets to my Door Arduino connected through wire to display. Show your twitter updates on a screen attached to your door at school's club office, classroom, treehouse room. Display to your audience your location at the... Continue >>

    Maintained by Qusay H. Mahmoud
    Content Contributors: Rudy Lang, Michael Lescisin, Rahma Mahmood, Ahmad Shamshiri, Ahmad Touseef, Mirna Zohiry