Arduino Final Project: Conga Line

In this project we will be creating a device which does the following:

  • Does nothing until a light is detected in a Photoreceptor
  • After light is detected, perform a task. Anything at all. Whatever you want it to do!
  • After the task is completed, turn on a blue light on the other end of the board.
  • This light will then activate the next Arduino… And so on, forming a long line of Arduinos.

The end result will look a bit like this except longer and with different tasks:

 

Basic Setup

Set up your breadboard as follows before you do anything else:


Note that power and ground are now running to the + and – lines on the edges of the board. This should help organize your device, whatever it is you decide to do.

 

What now?

Next, start thinking about what you want your device to do. Below are a few ideas, in case you happen to be blanking out:

  • Play a simple melody with the Piezo
  • Make a servo motor that rips a pin out of the breadboard, signaling the blue light to turn on
  • Write something the to LCD Screen
  • Pull a flag up a mast using a DC Motor and a lot of creativity.
  • Require a secret password combination on 3 buttons to continue.
  • Require a sequence of knobs to be turned to light up a sequence of lights, ending with the final blue light
  • Use the piezo to detect when somebody screams into the device.

All you need to do is make sure a blue light turns on when your task is completed.

 

HINTS

Please use hints only as you need to! Strive to figure as much out yourself as possible. (To use a hint, simply tap on the boxes below)

Can I see the code for the devices in the video?

No. Try to do it yourself!

[collapse]
PLEASE CAN I?

Fine. But do try and make something different.

The Pinwheel Motor

The LCD Screen

The Light Sequence

[collapse]
What about the circuits?

Well if I’m going to give away the code… I suppose I can do that.

The Pinwheel Motor

The LCD Screen

The Light Sequence

[collapse]

 

Reading Light

How do I check the light level?

The Photoresistor (Light Sensor) is hooked up to Analog Pin 0. Use analogRead(A0) to check the current light level. Think about saving it to a variable!

[collapse]
Okay but how do I check for a "bright" light?

Being “bright” is a bit of a relative thing. You just want to make sure that the light sensor reads that it is brighter than the normal room lighting.

A good starting point is to print out the light value to Serial.println. This will help you understand what the light values mean at any point in time.

I also recommend you create a function and call it something like “itIsBright()”, but that’s up to you!

[collapse]
How do I check the normal room light level?

Perhaps use analogRead once in the setup method, and save it to a global variable.

After that, if you want to check to see if the current light is brighter than the typical room lighting, you can do a comparison like: “if(currentLight > typicalRoomLight)”

[collapse]
How do I check if it is MUCH brighter?

Instead of just comparing against the typical room lighting, you might want to compare against something brighter. Try adding 100 to the typical Room Lighting variable in order to create a brightness threshold that must be passed.

[collapse]
How do I wait for the light before I do something?

There’s actually a few approaches you could take here.

You could use an if statement in the loop function, which reads:

if (itIsBright()){
    // Do Stuff
}

That would make sure we only perform a task if the photoreceptor is detecting a very bright light.

[collapse]
After we detect a light how do I do something ONCE?

An excellent question!

Boolean variables are our friend here.

You want to create a global bool variable and call it something like: “activated”

in your loop statement, you would write:

if(activated == false){
   // Do Something!
   activated = true;
}

This would only run once, since “activated” would be true from then on.

[collapse]
How do I turn on the Blue light when we are done?

See the hint block above this one. We’ll use a really similar bool variable… Perhaps called “done” and when done is true, we’ll make sure the only thing we do in loop is turn on a blue light.

There are other ways to do this as well!

[collapse]
Nah, I am just totally lost here.

No worries! Try reverse engineering this script. You can safely ignore anything about the motors:

The Pinwheel Motor

[collapse]

 

Component Help

How do I use a Piezo for detecting sound?

It’s as simple as having a Piezo with one end in ground, and the other in an analog input port! It doesn’t matter which pin on the Piezo goes to ground, so don’t worry about getting it backwards.

Use analogRead to detect the current frequency it is vibrating at.

[collapse]
How do I use a Piezo for creating sound?

See this tutorial here: PlayMelody Tutorial

[collapse]
How do I use a Knob Sensor/Pot/Potentiometer?

An excellent description of using the pot sensor can be found in project 05 of your book. Think of the pot as being a resistor you can change. As you turn the knob, the amount of electricity that gets through goes up or down.

[collapse]
How do I use a Servo Motor?

We’ve looked at the Servo Motor before, but here’s a great example to help get you on your feet: Arduino Servo Sweep

[collapse]
How do I use a DC Motor?

Controlling a DC motor can be tricky, and may involve the use of an electrical component you’ve not seen yet (A MOSFET Transistor). However, your best bet to get started here is to use the code and circuit designs for the sample used in the video above.

Pinwheel Code

PinWheel Circuit

As far as the Transistor goes, it works like a gatekeeper for electricity. When the “top” pin (relative to the circuit diagram linked above) is HIGH, it connects the bottom two pins together. This allows us to only complete a circuit when we want to.

[collapse]
How do I use the LCD Screen?

Ohhhhh Feeling ambitious are we?

It won’t be easy.

See this tutorial for a step by step guide… But please be aware, this component is the most difficult to work with of anything in your kit and will involve both a crazy circuit and an advanced program.

[collapse]
How do I use the Tilt Sensor?

This tutorial, though a bit dated, should have everything you need to know! https://learn.adafruit.com/tilt-sensor/using-a-tilt-sensor

[collapse]
How do I use the RGB LED?

Your project book contains a great example, but this Tutorial is even more clear: https://learn.adafruit.com/adafruit-arduino-lesson-3-rgb-leds?view=all

[collapse]
How do I use the Temperature Sensor?

In a very similar style to the way you’re using the light sensor as it turns out! See this tutorial for more details: https://learn.adafruit.com/tmp36-temperature-sensor/using-a-temp-sensor

[collapse]