Objectives: By the end of this session:

advertisement
Objectives:
 Be able to control LED’s by clapping
 Learn how to wire up a microphone
By the end of this session:
 You will have made the following circuit with a
microphone which turns an LED on and off when you
clap.
© S. Pithouse for use by Warwick Technology Volunteers
Page: 1
Arduino Uno
Breadboard
Jumper Wires
LED’s and Resistors
Capacitor
Transistor
Microphone
© S. Pithouse for use by Warwick Technology Volunteers
Page: 2
1)
Plug the microphone into the breadboard
2)
Plug the transistor into the breadboard, make
sure that the flat side is facing near the bottom
of the breadboard
3)
Push the capacitor into the board, it does not
matter which way around it goes in
4)
Push two resistors into the breadboard (make sure
that you use the ones without green/blue on
them).
5)
Push the resistor with a green/blue stripe into
the board.
© S. Pithouse for use by Warwick Technology Volunteers
Page: 3
6)
Connect a wire between the Arduino ‘s 5V pin and the
breadboard
7)
Connect a wire between the Arduino’s GND pin and
the breadboard
8)
Finally, connect a wire between the breadboard and
the Arduino’s Analog 0 pin
© S. Pithouse for use by Warwick Technology Volunteers
Page: 4
1)
Plug the USB cable into the Arduino and Computer, then open the Arduino
Program.
2)
Visit the webpage where you found this document —and copy and paste the
‘Clap sensor template program’ into the Arduino window.
3)
Upload the program and open the Serial Monitor
Make sure that the window has these values in the corner, if not, click on
the arrows and choose them.
4)
Clap, and watch the numbers change. They should get a lot bigger when
you clap. Remember the biggest number that shows, then add the following line of code to the part of the program shown below:
© S. Pithouse for use by Warwick Technology Volunteers
Page: 5
5)
Take away 100 from the big number, and type it after the equals sign:
6)
Add the following lines of code as shown below, this makes the program do
nothing until it hears a loud sound:
7)
Upload the program and open the Serial Monitor
8)
Nothing will happen until you clap, then a big number should appear on the
screen. You have just made a clap sensor!
9)
To make the program better, change the line beginning with ‘Serial.println’
to:
© S. Pithouse for use by Warwick Technology Volunteers
Page: 6
10)
Upload the program and open the Serial Monitor
11)
Now, a more relevant message displays when you clap. You can now add a
few extra lines to make an LED turn on and off:
12)
Upload the program and clap, you should see the Arduino’s LED turn on
and off!
© S. Pithouse for use by Warwick Technology Volunteers
Page: 7
Download