rG


DIY STEADICAM v 1.01
May 27, 2009, 3:00 am
Filed under: Photo/Video | Tags: , , , , , , ,

I added a Bogen 357 Quick Release Plate. Plus I’m working on a remote follow focus using a servo with arduino’s and xbee’s. WHAAAT?

This is the code for the sending arduino with the potentiometer

// SENDER

#define sensorPin 0 // analog pin 0 used to connect the potentiometer
#define threshold 0 // threshold for sending out values

int val; // variable to read the value from the analog pin
int lastSensorReading = 0;

void setup()
{
// start serial port at 19200 bps
Serial.begin(9600);
}

void loop()
{
char sensorValue = readSensor();

if (sensorValue > 0){

Serial.print(sensorValue, DEC); // print the value
Serial.print("\r");
delay(20);
}
}

char readSensor(){
char message = 0;

int sensorReading = analogRead(sensorPin);

sensorReading = map(sensorReading, 0, 1023, 0, 179); // scale it to use it with the servo (value between 0 and 180)

if (abs(sensorReading - lastSensorReading) > threshold) {
message = sensorReading;
lastSensorReading = sensorReading;
}
return message;
}

// End Sender

This is the code for the receiving arduino with the servo’


// RECIEVER

int val;
int inByte= 0;
char inString[6];
int stringPos = 0;

#include

Servo myservo; // create servo object to control a servo

void setup() {

// start serial port at 19200 bps
Serial.begin(9600);
Serial.println("Ready!");

myservo.attach(9); // attaches the servo on pin 9 to the servo object

}

void loop() {
if (Serial.available() > 0) { // are there any bytes available on the serial port ???

handleSerial();
}
}

//------------
void handleSerial() {

inByte = Serial.read();
if ((inByte >= '0') && (inByte <= '9')) {
inString[stringPos] = inByte;
stringPos++;
}

if (inByte =='\r') {
int val = atoi(inString);
Serial.println(val);
myservo.write(val); // sets the servo position according to the scaled value
delay(15);

for (int c = 0; c < stringPos; c++) {
inString[c] = 0;
}
}
}
//------------

// End Reciever

Advertisements