The Mini-World of Color: A Beginner Arduino Project

One of my favorite projects in my Electronics class is the Mini-World of Color. In this project, students create a synchronized light and sound show, complete with instructional video and tutorial.

We start with a couple of lessons on how to do the basic blinky LED on the Arduino, and then the RGB LED.  The kit we use is the Sparkfun Inventor’s Kit. Each student checks out a kit at the beginning of the semester, and they breadboard all of their projects.

The RGB LED lesson, above, introduces kids to the idea of a function. I decided at this time to make it optional to use functions. When I was a new programmer, I know it taught me a lot to do programs the long, inefficient way a few times so I really understood the beauty of functions later. But in the lesson, I show how you can compress multiple lines of code into a single function this way.

Before: 3 lines of code to make each color in the RGB LED

void setup()
{
pinMode(9, OUTPUT);
pinMode(10, OUTPUT);
pinMode(11, OUTPUT);
}

void loop()
{
analogWrite(9, 255);
analogWrite(10,0);
analogWrite(11,0);
delay(500);

analogWrite(9,255);
analogWrite(10,0);
analogWrite(11,255);
delay(100);
analogWrite(9,0);
analogWrite(10,0);
analogWrite(11,255);
delay(100);
}

This section of code combines the red and green lights into a single function. I challenge the students to add what’s needed to turn it into a single function that lights up the RGB LED with all three colors: red, green, blue.

void setup()
{
  pinMode(9, OUTPUT);
  pinMode(10, OUTPUT);
  pinMode(11, OUTPUT);
}
void lightColor(int red, int green)
{
  analogWrite(9, red);
  analogWrite(10, green);
}
void loop()
{
   lightColor(255,0);
   delay(500);
   lightColor(0,255);
   delay(500);
}

The next task is to learn to use the Piezo buzzer, which we do with some example code the students can hack. For a “3” grade, they have to modify the code to generate more than 1 note and make both LED’s light up. For a “4” grade, I ask them to write a function called playNote() which plays a note, compressing multiple lines of code into one.

Instructions for Piezo Circuit

Some students learn functions very flexibly at this point, and others won’t use them consistently… they will still copy and paste six lines of code for each note. This is fine. It gets the job done, and they’ll learn by creating inefficient code now.  For students that are ready to make more efficient code, I think this was helpful to them!

These activities bring us to where we are today. I talked with the students about being a Disney Imagineer. The Imagineers are some of the best, brightest engineers in the world, and it’s a very prestigious job. They are tasked with making Disney into a fully immersive experience, through rides, attractions, exhibits, movies, and so on.

I show the students a YouTube video that shows the Disney World of Color attraction at California Adventure. Most have never seen it. It’s a feast for the senses!

Their unit project is to use what they have learned about Arduino outputs to make a synchronized Mini World of Color. It uses the piezo and LED’s, but at its bare bones, it’s what the Imagineers do to create the World of Color show using a microcontroller, color mixing, sound, and coding.  Students find a song and transcribe it into frequencies for the piezo. Some look up sheet music online and transcribe the notes, while others play the song on a virtual piano and write the notes they play, and in some cases  you can find the notes and beats written out – making transcription into a song easy. Some resourceful students even download an existing music project they find and re-create it and then modify.

Students are required to make a video of their project, as well as a how-to technical video explaining the code. This is a sample from last year, playing “America the Beautiful”. These kids did an awesome job and used excellent teamwork. It was a big effort to transcribe all of those notes into Arduino code!

Student Project: America the Beautiful

I don’t have any requirements for how they write the code. It can be elegant or messy, long or short, efficient or dreadfully inefficient, well-commented or not. They might use variables and functions, or not. We will reflect on coding best practices later, but I believe they’ll learn more if they are allowed to take whatever path makes sense for them to accomplish the goal.

I can’t wait to see the creations from this semester’s group of kids. They are already planning and writing their musical light shows. One student is going to do the Star Spangled Banner while another is working on the main theme from Zelda. I joked about giving extra credit for the 1812 Overture. Maybe someone will take me up on it this year.

It’ll be a lot of fun!

Advertisements

Tags: , , , ,

About dupriestmath

I'm a former software engineer who has taught middle school math and computer science for the past 6 years. I believe every kid has the right to be a thinker. I started this blog to save resources for integrating programming in the Common Core math classroom. I also use it to save my lessons and reflections from teaching budding computer scientists! Coding has transformed how I teach and think. You'll love what it does for you. You should try it.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: