ECE497 Project Christmas Light Controller

From eLinux.org
Revision as of 10:52, 14 November 2016 by Gfrung4 (talk | contribs) (Beautified highlights.)
Jump to: navigation, search

thumb‎ Embedded Linux Class by Mark A. Yoder


Team members: Josh Woods and Ricky Rung

Grading Template

Draft Feedback

Looks good. Keep up the good work.

Could you add some pictures to show what you are doing?

I'm using the following template to grade. Each slot is 10 points. 0 = Missing, 5=OK, 10=Wow!

00 Executive Summary
00 Installation Instructions 
00 User Instructions
00 Highlights
00 Theory of Operation
00 Work Breakdown
00 Future Work
00 Conclusions
00 Demo
00 Late
Comments: I'm looking forward to seeing this.

Score:  10/100

(Inline Comment)

Executive Summary

Image

Click for Video

Our project is to create a user interface to control 320 LED lights on a 10 meter LED strip. The LED strip will then be put on the ECE Department’s tree during the holiday season.

The interface will be online, and will allow anyone to write code to control the lights on the tree. Users will also be able to select patterns that others have programmed, if they don’t want to write their own.

Submitted programs will each run for a specified length of time. A queue will be used, so if multiple people write programs at once, each program will get a chance to run. When one program’s run time expires, the next program will run, until the queue is empty. If no programs are waiting to run, the last run program will continue indefinitely.

There will also be a speaker near the tree which will play holiday music, selected through the online interface. A separate “music queue” will be used to store songs to play. Users will be able to select from a list of songs to add music to the queue.

This will be a fun and exciting holiday feature for the ECE department.

Needed Hardware

In addition to a BeagleBone, you will need:

  • Adafruit's LPD8806 LED String
    • Sold by the meter. Need to order 5 meters for a roll. Our project uses two rolls, for a total of 10 meters. The code can be easily adapted for more or less lights as needed.
  • 5V Power Supply
    • The LEDs use a lot of power. We used a 5V, 5A power supply to power our 10 meters, but we needed more power to have all the LEDs on full brightness. Adafruit sells a 5V, 10A supply, linked above, that they recommend to power the LEDs.
  • USB Audio Dongle
    • Necessary if you want to use the BeagleBone to play holiday music. Connects to the USB port of the BeagleBone and has a 3.5mm audio output.
  • Speaker
    • Must be connected to the output of the USB Audio Dongle to play music for everyone to hear. Headphones can be used instead for testing.

Installation Instructions

Software Setup

git clone https://github.com/gfrung4/ECTree.git
  • Run the install.sh script in the repository. This needs to be run only once, but might take a while.
cd ECTree
./install.sh
  • Run the setup.sh script in the repository. This needs to be run every time you start up your BeagleBone.
./setup.sh

Hardware Setup

  • Connect the 5V power supply to the VCC and ground pins of the LED strip.
  • Connect the CLK pin of LED strip to P9_22 of your BeagleBone.
  • Connect the DI pin of the LED strip to the P9_18 pin of your BeagleBone.
  • Connect the ground of the power supply to the ground of your BeagleBone.
  • Plug the audio dongle into the USB port on your BeagleBone, and connect a speaker or headphones to the audio output of the dongle.

Running

  • Run the server script, web.js.
./web.js

Troubleshooting

  • You may not have permissions to execute the web.js after cloning the repository. If not, you'll get this error:
-bash: ./web.js: Permission denied

This can be resolved by giving the owner of the file execute permissions, using this command:

chmod 744 web.js

Then try running it again and it will work!

./web.js
  • You may get an error when running web.js if something else is using port 80. This error looks like this:
events.js:85
      throw er; // Unhandled 'error' event
            ^
Error: listen EADDRINUSE
    at exports._errnoException (util.js:746:11)
    at Server._listen2 (net.js:1158:14)
    at listen (net.js:1184:10)
    at Server.listen (net.js:1269:5)
    at Object.<anonymous> (/root/ECTree/web.js:237:6)
    at Module._compile (module.js:460:26)
    at Object.Module._extensions..js (module.js:478:10)
    at Module.load (module.js:355:32)
    at Function.Module._load (module.js:310:12)
    at Function.Module.runMain (module.js:501:10)

If you get this error, it means bonescript is running automatically on your BeagleBone, and is using port 80. To resolve this conflict, you can either change the port that ECTree runs on or stop bonescript. To stop bonescript, just run these two commands. Don't worry! This won't be permanent. It will only be stopped until the BeagleBone restarts. This does mean, however, that you'll need to run these commands each time you start your BeagleBone.

systemctl stop bonescript.socket
systemctl disable bonescript.socket

If you'd rather not stop bonescript, you can also change the port ECTree runs on. Open web.js in your favorite text editor and find this section:

http.listen(80, function() {
    console.log('The server has started.');
});

Change 80 to some other port number that is not used for something else on your BeagleBone. The disadvantage of this is that you'll have to include that port number when accessing the web interface, so instead of http://ip, you'll have to go to http://ip:port. If you don't want to have to include a port like this, do the disable bonescript steps above instead.

Once you've disabled bonescript or changed the port, try running again and the error will be gone.

./web.js

User Instructions

  • Once the web.js server is running on the BeagleBone, you can access the web interface by pointing your browser to your BeagleBone's IP address. If your BeagleBone is connected to your computer via USB, that IP address is 192.168.7.2, so open your favorite web browser, type 192.168.7.2 into the address bar, and press enter.
  • Once there, you should see the interface:

frame User Interface

  • You can click Write Program to begin writing code.
  • If you need help getting started, click the Learn button in the navigation at the top of the page. This will take you to the tutorial.

frame Tutorial Interface

  • After completing the tutorial, you will be able to see your lights in action! You can then write more programs from the main page, now that you know how to do it! Enjoy the light show!

Highlights

  • Thanks to the Bootstrap framework, our user interface will work on any browser including smartphones. This makes it easier for people passing by to change the lights! It's difficult to write programs on a smartphone, but previously written programs can be easily selected, and music can be added to the queue as well.
  • While our project allows any user to write code to control the lights, the code actually runs in the user's browser and the result is sent to the BeagleBone in the form of a list of "frames". This keeps our BeagleBone safe. Running arbitrary code submitted by users on the BeagleBone itself would be a major security flaw. Anyone could just write an infinite loop and crash the program! Or worse, they could write code that called commands to delete everything on the BeagleBone or take control of it for malicious uses.
  • All light display patterns made by the users are saved for future use. Although the interface only displays the most recent 10 patterns, it would be easy to modify to support searching through all past patterns. This gives people who don't want to code a variety of fun programs to run.
  • The code is written in a way that allows more audio files to be easily added to expand the list of holiday music the BeagleBone can play.

Theory of Operation

We have a server that is listening on port 80 for user's to connect. once a user connects the web page request all current queue information and displays that information for the user to know how long until their pattern or song will be played. The server handles all of the request from many users to maintain unity among all the users so that everyone sees the same queue. the display patterns are sent from the user to the server using a json object and not actual code to prevent bad code spinning the server out of control.

Work Breakdown

  • getting lights to interact with the bone : Ricky
  • build a server : Josh & Ricky
  • build user interface : Josh & Ricky
  • pattern queue : Josh & Ricky
  • audio queue : Josh
  • beautifying website : Ricky

Future Work

If we had more time, we would have liked to make the lights "dance" to the beat of the music.

Conclusions

I, Josh, really enjoyed working on this project because I got to learn and explore some of the aspects of web programming. It will be nice to come back to campus after fall break and see the project in use and see how much action the lights will be getting.




thumb‎ Embedded Linux Class by Mark A. Yoder