Wednesday, November 18, 2009

Lab6-Analog Output

Connect Power from Arduino to Breadboard:
Using the conventional red and black wires, the Arduino power and ground pins were connected to both sides of the breadboard.

Servo and Sensor:
A potentiometer was connected to the Arduino input pin 0. The servo motor was connected to power and ground, and the 3rd wire (orange) was connected to the Arduino digital pin 9.


Programming:
The provided coded was loaded to the Arduino board. The servo motor mapped from 0 to (almost) 180 degrees, as the potentiometer value shifted from 0 to 1023.

Speaker Setup:
The servo motor was removed from the circuit. A speaker was connected to ground, and the other end was connected to a resistor, which in turn was connected to the Arduino digital pin 8.


Tone Library:
The Tone library was downloaded from the Arduino website and installed into the Arduino libraries folder. The provided code was then loaded to the Arduino board, and the speaker tone output responded to the potentiometer input.

Create Something Unique:
Using the servo motor attached to a lever (chopstick), a target sign was attached to the end of the lever to oscillate back and forth. The target sign had a small hole in the center for a photoresistor.

The photoresistor value was read as input into the Arduino code, and if the light value was high enough the servo motor was activated to move along its oscillation. A NERF gun was outfitted with a flashlight scope to shine a light where the gun was aimed. With these components in place, an impossible target system was created. Once the gun was aimed at the target, the target would move away.

Video: http://www.youtube.com/watch?v=1jFErmvWepQ

No comments:

Post a Comment