I made a earlier project using the pan/tilt kit and the Wii Nunchuk and thought it might be fun to control the pan/tilt with the accelerometer but then came up with a better idea. Make a self leveling platform using the pan/tilt kit and an accelerometer. It's pretty basic and the code is very simple. There is lots of room for improvement but hopefully can be some inspiration for you.
Parts used (I get a lot of my parts from Adafruit but use anything you have)
- Adafruit ADXL345-Accelerometer
- Arduino Uno
- Pan/Tilt Kit
- Breadboard
- 9V Battery and battery clip
- Foam board (for housing)
Connect the accelerometer as follows:
- VIN --> 5V on breadboard 5V rail
- GND --> Ground on breadboard GND rail
- SDA --> Analog A4 on Arduino
- SCL --> Analog A5 on Arduino
Connect the servos as follows:
Servo 1
- Brown Wire --> Ground on breadboard GND rail
- Red Wire --> 5V on breadboard 5V rail
- Brown Wire --> Pin 10 (Used Yellow Wire)
Servo 2
- Brown Wire --> Ground on breadboard GND rail
- Red Wire --> 5V on breadboard 5V rail
- Brown Wire --> Pin 10 (Used Blue Wire)
I used foam board to make a housing to hold the servos, accelerometer and Arduino.
The code has a few variables that can be adjusted.
- xOffset - Used to level out the platform on the x-axis
- yOffset - Used to level out the platform on the y-axis
- sensitivity - Used to decrease the sensitivity of the accelerometer
There are two libraries needed:
- Adafruit_ADXL345_U.h
- Servo.h (builtin to the Arduino IDE)
The code is pretty well commented but if you have any questions, feel free to leave a comment and I will answer as best I can.
See it in Action!Final ThoughtsOther ideas:
- Use the accelerometer to aim a laser attached to the pan/tilt
- Use accelerometer in a robot
- User stepper motors for better resolution
As always, feel free to comment and hope this is entertaining and useful. Thanks for looking!
Comments