Goal: Build a night time alarm to sound when night falls
Materials: Arduino Microcontroller, Piezo buzzer, photoresistor, 150k resistor, jumper wires,
(To learn more visit http://www.zombiebothq.com/components)
Overview: This challenge adds some braaaains to our electronics, in the form of an Arduino microcontroller. A microcontroller receives input from the environment around it (from light sensors, temperature sensors, switches etc.) then perform actions based on these inputs. Using this combination of input & output we can do just about anything we like.
Instructions:
- From this challenge onwards, we’ll be using the website to provide detailed instructions for each challenge. Visit http://bit.ly/ZOMBIE-3 (All upper case) for pictures, videos and tips. (Or visit http://www.zombiebothq.com and click ‘The Challenges’. )
- Download, install and set up the www.arduino.cc software.
Stage One: Make the Light Blink - Set up your breadboard like this.
- An Arduino program is called a sketch. Helpfully the Arduino software comes with a lot of sketches already written for us. Today, we’re going to use one of the pre-written examples called ‘Blink’. Open the Arduino software, then go File > Examples > 01. Basics > Blink. Now send it to the Arduino by going File > Upload (make sure the USB cable is connected). Your L.E.D. should start flashing. If you want to get adventurous, see if you can speed the blinking up, but changing the code. Find where the program turns the L.E.D. on for 1000 milliseconds, then turns it off for 1000 milliseconds. Have a play around with these numbers and re-upload your sketch to see if you can speed up the blinking.
Stage Two: Create a Night-time Alarm: - Time to get serious! Let’s build a light sensor like the one below using the photoresistor, the 150k resistor and three M/F jumpers. Carefully twist one of the resistor legs around one of the photoresistor legs (be careful not to wiggle the legs too much because they do get weak and break). Now add M-F jumpers, matching the colours to the photograph below.
Also make a piezo buzzer from the buzzer and one green and one black M/F jumper. (Fig. 3). It doesn’t matter which pin you attach the green and the black jumpers to; it’ll work either way.
- Now let’s put it all together and build a light sensor that detects how much light there is in the room and adjusts the noise made by the piezo buzzer. First things first: set up your breadboard like this. We’ve written a couple of sketches that we can use with your light sensor. Download and unzip this file: Zombiebot_Challenge_Three. Once you have unzipped the two sketches, open the one called ‘Zombiebot Night Time Alarm v2‘ with the Arduino software. If you have put all of the wires in the right places and set your breadboard up properly, the green L.E.D. should light up. Cover the light sensor with your hand to amke the red L.E.D. light up and the piezo sound. You’ve made an alarm with will activate when the light in the room drops below a certain point!
- Extra fun: once you have successfully built your night time alarm, open the second sketch (‘Zombiebots Play A Tune v1‘ and upload it to your Arduino. Can you recognise the tune? When you have worked it out, re-upload the first sketch to return yout setup to being a night-time alarm.
You will use these skills later by: We will eventually use two photoresistors for our robot. They will act like eyes so that when the robot senses it is heading into a corner, it will adjust direction.