Filed under: Photo/Video | Tags: arduino, bogen, code, diy, nikon d90, stabilizer, steadicam, xbee
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
9 Comments so far
Leave a comment
sweet
Comment by Wesley Clouden June 1, 2009 @ 6:06 amNice work!!! I have a couple of questions though,
1. What arduino board did you use… was it this one?http://www.robotshop.com/arduino-usb-microcontroller-board-1.html
2. It looks like there is something on top of the arduino, where the potentiometer is connected, could you clarify?
3. What model of the xbee did you use, and where did you buy it?
Thank you so much for this post your awesome!!!!
Comment by Frederick Ross March 26, 2010 @ 9:24 pmHey man,
Comment by ed March 29, 2010 @ 5:53 pmare you still working on the follow focus? did that ever get completed? also, was it trial and error in figuring out the distribution of weight on the steadicam?
Hi Raf,
Thanks for making this available. This is totally awesome! I am currently working on a stereoscopic mirror rig for 3D shooing. I would like to build your arduino follow focus unit. However, I need to control two cameras at the same time in sync using the same controller. If I build two receivers do you think they’ll both pick up the signal if they’re on the same frequency? Or would I need an additional line of code so that the controller knows there are indeed two receivers? I am very new to arduino and currently waiting for the book “Getting Started with Arduino” (It’s getting mailed to me this week).
Thanks!
Comment by Efrain Melendez May 13, 2010 @ 5:20 amEfrain,
Comment by rafgodlewski May 15, 2010 @ 4:16 amSuper easy. As long as the receiving radios have the same address and the sending radio is set up to broadcast to multiple radios it will work. I am a little confused tho, your rig with the two cameras is one rig correct? meaning the two cameras are positioned on the same frame let’s call it. If that’s the case you would still only need one receiving xbee, one sending xbee, and two servo motors or stepper motors (whichever u prefer) Let me know how it goes, I’d LOVE to see some pictures!
in regards to that person’s error they were getting , could you post the solution here on the blog? ( just in case someone else is having the same issue, they’ll be able to see the solution ).
ps : have a link to each item that you purchased so we can purchase similar items online?
thanks again!
rocksteady,
Comment by danno June 6, 2010 @ 6:02 amdanno~
You just have to add the servo library. The little line of code needed is filtered by WP for some reason. Look on arduino website on how to do it if you’re not familiar with it.
Comment by rafgodlewski June 19, 2010 @ 3:48 am