Project Illuminate Home

First Bytes

Project Illuminate

Controlling the Lights


Now that the hardware is set up, let's take a look at the software. Software is the programs that tell the hardware what to do. We've already seen an example of a piece of software that controls the Arduino board: the Blink program. Now let's begin looking at software to control the lights through the Arduino board.

To begin, you'll first need to download the First Bytes framework. Right click on the link below and then save the file into your home directory. (Note that if you don't specify the directory, it will save to your Downloads directory, and you'll want to move it from there to your home directory.)

First Bytes Framework

Then, using the terminal from which you opened the Arduino IDE, type the following commands, which will unzip and expand the archive you just downloaded:

gunzip firstbytes_framework.tar.gz
tar -xvf firstbytes_framework.tar

Next, we need to open the Project Illuminate framework. From within the Arduino IDE, select File->Open. From there, navigate to your home directory and click on the firstbytes folder. Within that directory, you'll find a project_framework folder. Double click on that and and then again on project_framework.ino.

The Arduino sketchbook called project_framework should be opened.

This framework already consists of a few files (indicated by the tabs across the top), and you may add your own as you progress in the project. The pre-existing files are briefly described here, and we'll look at some of them more in-depth below.

Some important things to note before we begin programming:

Task 3.1: Blink Light 0

Before you can use the lights we'll need to do one more thing: add a library to your Arduino setup. A library is a collection of already-written functions available for you to use. To add the FastLED library, you'll want to find the Sketch menu option on the top toolbar of the Arduino IDE. Click on Sketch, click on Include Library and then click Manage Libraries..., and a new window will pop up. Search for FastLED, and then click Install.

Now, let's look at the tests file. At the top of this file, there is a function called blink_light_0_example, which is provided for you. Take a careful look at that function and convince yourself that you understand its contents. You'll also notice that this function is called from the loop() function inside the project_framework file. When you are ready, test the example by uploading it to the Arduino board (use the arrow pointing to the right as you did to blink the LED). The lights will first perform some tests where they alternate PaleVioletRed and SteelBlue, and then the code in the loop() function will begin to execute. In this case, that code is our blink_light_0_example().

If the code works properly, you should notice light 0 blinking white. (Notice that this is light 0 and not light 1!) Now, change the code to do the following things:

Task 3.2: Blink the First and Last Lights

For our next test, let's blink both the first and last light. Recall that we have 25 lights. If the first light is number 0, what do you suppose the last light is?

Using the information you learned in Task 3.1, complete the blink_light_0_and_24() function in tests so that the first and last lights blink. Test your function by commenting out the call to blink_light_0_example in the loop() function in project_framework and uncommenting the call to blink_lights_0_and_24() in that same function. Please ask if you need help!

Task 3.3: Blink All Lights

In your C++ tutorial, you learned how to use loops. Using a loop, complete the blink_all_lights() function so that every light blinks. Once again, test it by commenting out any calls to other functions in the loop() function in project_framework and uncommenting the call to blink_all_lights() in that same function.

Congratulations! You are able to control the lights! Now you are ready to begin doing more complicated things. Next, you'll learn to create basic patterns.