Westy92.com If you're bored enough, go ahead and read this. :)

13Nov/104

Arduino Pan/Tilt Platform Controlled With a Wiimote

I have recently purchased 4 servos from HobbyPartz.com. These were my first servos, and I decided to go the cheap route. I now wish I wouldn't have, as these are pretty much junk. They work, mostly, and are not built well at all. I would not recommend these to anyone or buy them again myself.

The reason I did this project was not even my idea. A friend wanted to make the pan/tilt platform for a tripod, using this for inspiration.

I, too, started my research there. I did not need to use 4 servos, but only 2. The very first thing I did was install Python. I had problems with other versions, so I installed 2.7 32 bit even though I am on a 64 bit laptop.
I then installed the pyserial module.
following that, the servo.py file.
I only had to modify one line of code, the USB port. I am currently running ubuntu, so I changed it to "usbport = '/dev/ttyUSB2'" instead. If you are running Winblows, you need to change it to the appropriate port looking somewhat like this: "usbport = 'COM3'".

Now for the fun hardware part. I have an Arduino Mega, but any Arduino should be sufficient. All you really have to do is locate 2 servos, your Arduino, 9 wires, and a breadboard. Connect the 5V pin on the Arduino to one part of the breadboard, amd the GND to another. Then connect the 2 servos to that power. With the remaining 2 wires, connect each servo signal wire to a PWM pin on the Arduino board. I used pins 8 and 9.

Now for the Arduino programming...
Download this.
Change it to this:


You now should be able to open up terminal, type "python" and then type "servo.move(1,180)" and it will move servo number 1 to 180 degrees.

Now I want to be able to control it with my...Wiimote!

First, we need to install the "cwiid" module. Type "sudo apt-get install python-cwiid" in Terminal to install that.

Now comes to my actual coding. All of the source code files previously have all been from, or alterations of files from here.

Now you need the first file that I actually coded:

When you run this code, it asks you to press 1 & 2 on your Wiimote. Then it sets the servos to their neutral position of 90 degrees.
It listens for input from the d-pad.
To exit, press the Home button on the Wiimote.

Enjoy!
--Seth

Filed under: Arduino Leave a comment
Comments (4) Trackbacks (2)
  1. Great information! I’ve been looking for something like this for a while now. Thanks!

  2. You buy a 5gram servo with Stall Torque: of 0.8kg/cm for a Pan&Tilt!!!!!!?????
    They are far Far FAR too small unless all you are doing is moving a camera got from a cell-phone.

  3. This is simply a proof-of-concept and I just used the servos I owned. Also notice that my “frame” is made of cardboard. :P


Leave a comment

(required)

Login with Facebook:

online games juegos gratis games online free games free online games
online game jogos online jeux gratuits giochi gratis oyunlar