I like to control a servo from a PC running Processing 1.2. The ServoMotor (Modelcraft RS-2) is connected to an Arduino Duemilanove board. I found several forum post around with different ways to set this up... but none seems to work for me. My final project will be more complex later - but because of the bugs and strange servo movements i tried to scale it down to the most simple setup in this forumpost.
What i did so far...
1. installed Arduino 0019
2. installed FTID to USB driver vers. 2.8.2.0 from 12.07.2010 (works, COM8 is my new serial port to Arduino)
3. set driver properties to 57600bps, databits 8, parity none, stop bits 1, flow control none
3. compiled and uploaded StandardFirmata in Arduino 0019 (works, no error)
4. starting Processing - running the following sketch
/** * Servo test 001. * * Should turn the Servo to its max range and back. * Only once. * */
import processing.serial.*; import cc.arduino.*;
Arduino arduino; int servoPin = 9;
void setup() { noLoop();
println(Arduino.list()); arduino = new Arduino(this, Arduino.list()[1], 57600); arduino.pinMode(servoPin, Arduino.OUTPUT); }
void draw() { for (int i = 0; i < 255; i ++){ arduino.analogWrite(servoPin, i); delay(1000); }
delay (3000);
for (int i = 255; i > 0; i --){ arduino.analogWrite(servoPin, i); delay(1000); } }
The Servo moves a about 20 times fast back and forth (max 15 degree). Between every movement it waits for 4 seconds - and than a "Error inside Serial.serialEvent()" appears. Strange behavior...
I don't have any glue where to look for the bug.
Any suggestions are appreciated...