Spy on your cat with this robot camera. Mount the camera robot and control it with a small joystick. You can run everything from the computer and when you see your cat doing something suspicious, take a picture!
Materials
- 1 Arduino Uno board
- 1 Basic Education shield
- 2 standard servo motors
- 1 tinkerKit Joystick
- 3 jumper wire
- 2 TinkerKit wires
- 1 Web camera
- 1 Robot camera kit
- 8 AA batteries
- 1 AA Battery holder
- 1 power connector
Instructions
Code
You cand find the code at: File -> Examples -> BasicEducationShield-> Robots -> CameraRobot
How it works
We read the values from the joystick. These values will be either 0, -1 or 1 for each axis. 0 is set to the middle, whereas, -1 is one side, and 1 is the other side.
Arduino can only drive one servo at a time. So we can only move one of the servos while the other one is still. Therefore we check first to see if panJoystick
, the X value is anything but 0. That is -1 or 1. If it is, we detach the tilt servo, attach the pan servo and move it by adding or subtracting from the angle.
If however panJoystick
is equal to zero we detach the pan servo, attach the tilt servo and move it according to the tiltJoystick
value.
Troubleshooting
- Make sure you connected the servos correctly. See the reference to make sure the servos work.
- Make sure you have connected the joystick correctly. See the reference to make sure it works.
Experiment further
- Are the servos moving too slow or too fast? Change the
delay
in the end ofloop
or change the increasing and decreasing steps of the angles. - Are the servos moving too far to the sides, or too much up and down? Limit the angles allowed.