Saturday, April 21, 2012

Arduino controlling a stepper motor.









I salvaged a stepper motor from an old scanner.I used an Arduino Motor Shield on top of an Arduino,  which the motor shield is useless in this configuration.

The stepper motor has six wires.

To determine the pinout of the stepper motor I connected my multimeter to each pair of wires(from the motor) possible. The two pair of wires that have the highest resistance are connected to pins 8,9,10,11 on the Motor Shield.
The other two wires I have connected to 5V and GND.












I used the stepper_oneRevolution Arduino example program.



Sunday, April 8, 2012

Pan and Tilt Mechanism with 2 Parallax Servos and an Arduino

Here is an Arduino controlled pan and tilt mechanism. 

I used two parallax hobby servos available at Radio Shack. I could have ordered some specialty brackets online, but I have little patience. 

I soldered some header pins onto a perf board for connecting the servo plugs to a prototyping board.


Here is a wiring diagram...  


Control is allowed with 2 100K ohm potentiometers ..  I think ultimately I will connect it to an analog thumbstick that has been collecting dust for a while.














The code is based on the Arduino Knob example program.
// Code to allow the arduino to control 2 servos independently  ..
#include <Servo.h> 
Servo myservo;  // create servo object to control a servo 
Servo myservo1;
int potpin = 0;  // analog pin used to connect the potentiometer
int potpin1 = 1;
int val;    // variables to read the value from the analog pins
int valu;
void setup()
{
  myservo.attach(9);  // attaches the servo on pin 9 and 10 to the servo object
  myservo1.attach(10);
}
void loop() 
{
  val = analogRead(potpin);            // reads the value of the potentiometer
   valu = analogRead(potpin1);
  val = map(val, 0, 1023, 0, 179);     // scale it to use it with the servo s
   valu = map(valu, 0, 1023, 0, 179);     
  myservo.write(val);                  // sets the servo position according to the scaled value
   myservo1.write(valu);                 
  delay(15);                           // waits for the servo to get there
 }            


  

Sunday, April 1, 2012

Arduino Pan and Tilt Mechanism with Parallax Servos

  I am working on an Arduino controlled pan and tilt mechanism. (pic top right)
It has two parallax hobby servos available at Radio Shack. I could have ordered some specialty brackets online, but I have little patience. 


  I have the Arduino environment installed and it looks like basic implementation is going to be pretty easy. Arduino has a pretty extensive online knowledge base.


   I soldered some header pins onto a perf board for connecting the servo plugs to...  
  
  Working on setting it up to allow control with 100K ohm potentiometers ..  I think ultimately I will connect it to an analog thumbstick that has been collecting dust for a while. I have not decided.


 I been pulling my hair out the last couple of evenings getting it to control 2 servos with separate potentiometers  simultaneously...


  When I have it working I will post a video to youtube and I will post the code/wiring diagram here.