Project Illuminate Home

First Bytes 2014

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.

First, put the USB stick you have been provided in the remaining USB slot on the front of the computer. Then navigate to your USB stick on the computer by once again going to the Start menu, and then clicking Programs->Accessories->Windows Explorer->Removable Disk (E:).

Once you have accessed the USB stick, then double click on the pattern_framework folder and then again on pattern_framework. This sequence should open an Arduino sketchbook called pattern_framework. Important: Save all your work to the USB stick. When you log out of the lab machine, the machine is scrubbed for the next user, and your work will be lost.

Note: If you are doing this from home and not as part of the First Bytes camp, you can download the framework.

This framework already consists of many 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 1: Blink Light 0

Now, let's look at the test.cpp 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 pattern_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 turn white and then alternate red and blue, 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 2: Blink the First and Last Lights

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

Using the information you learned in Task 1, complete the blink_light_0_and_15() function in test.cpp so that the first and last lights blink. Test your function by commenting out blink_light_0_example in loop() and uncommenting blink_lights_0_and_15(). Please ask if you need help!

Task 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 the other functions in loop() and uncommenting blink_all_lights().

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.