"This instructable was created in fulfillment of the project requirement of the Makecourse at the University of South Florida (www.makecourse.com)"
This Instrutable is for the construction of an automated turret. Mine has a laser pointer attached to it, but many other devices could be guided with the aid of this robot.
This particular model uses HCSR04 proximity sensors to "track" objects in attempt to face them. Once the robot feels that it has faced an object it will begin a firing command.
Step 1: Block Diagram
The basic concept here is that the URMs will take readings. then the Arduino will interpret those readings. The arduino will then command to traverse servo to rotate. Once the turret has swiveled over, the URMs will read again. If the conditions are meet the traverse servo will hold still while the trigger servo activates the laser pointer. If the conditions have not been meet then the traverse servo will be commanded to readjusts, or wait, depending on which conditions have not been meet.
Step 2: Structure
The basics of the structure:
Chassis: Holds the Arduino micro controller and a possible internal power supply.
No particular shape required, but make sure you have enough space. You'll want to try and keep this light weight.
Base: Mount the servo horns to this, and the leg parts. This can be heavy, and probably should be. Keep it flat so your bot doesnt end up top heavy.
Legs: Make sure these guys have a nice long reach. The robots swivel will pull them up of the surface otherwise.
Step 3: Circuit
These is pretty straight forward. Simply connect each trigger and echo pin from the ranging modules to the board
also connect the control wires for the servos, insuring you use an appropriate pin.(different boards have different types of pins, and some cannot be used for servos. On this Mega any pin can work a servo.)
Dont forget to supply 5 volts to everything and ground it.
I've covered my bread board in layers of electrical tape and then punched the wires thru it, this will make the ranging modules more stable.
Step 4: Code
This code should work as is. Key values that you may want to change are the pins, and the max scan range.
If you decide to attach something other than a servo activated laser pointer to the robot, you'll need to edit the contents of that loop accordingly.
This code uses an object called HCSR04ProxSensor. it has a single method attached that will take the reading for whatever proxsensor it is coupled to.
The basic idea is to take several readings, average them, throwing out any bad values, and then finding which one is smallest. Once the smallest value is found the program will take the distance of the sensor that came back with said reading, and the reading itself, and use a tangent inverse function to determine the next rotation of the turret.
Other than that its mostly basic programming stuff.