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)
No. Try to do it yourself!
Fine. But do try and make something different.
Well if I’m going to give away the code… I suppose I can do that.
Reading Light
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!
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!
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)”
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.
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.
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.
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!
No worries! Try reverse engineering this script. You can safely ignore anything about the motors:
Component Help
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.
See this tutorial here: PlayMelody Tutorial
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.
We’ve looked at the Servo Motor before, but here’s a great example to help get you on your feet: Arduino Servo Sweep
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.
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.
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.
This tutorial, though a bit dated, should have everything you need to know! https://learn.adafruit.com/tilt-sensor/using-a-tilt-sensor
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
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
Recent Comments