Servo/ESC control via Processing and Firmata

Hello, I'm trying to control an RC electronic speed controller (ESC) from Processing on my Mac. ESCs use the same control signal as a regular RC servo, so I'd appreciate advice from anyone who has experience with either. If you're curious, a 0? servo signal to the ESC runs the motor in full reverse, 90? is stopped, and 180? is full forward.

I know my wiring is right, because I can control the motor from the servo mode slider in the Firmata Test application, and I can also use the "sweep" example code on the Arduino Servo library refpage to make the motor run back and forth without intervention from the computer.

In a nutshell, I need to control this ESC (or servo, however you like to think about it) in real-time from my Processing sketch. I know only one Processing command that helps towards this end, and that's "arduino.pinMode(escPin, Arduino.SERVO);", called in setup().

Anyone know what Processing syntax will actually set the servo to a certain angle?

I tried "arduino.analogWrite(escPin, speed);" inside of draw(), after executing the above command in setup(). "speed" was assigned various int values from 0-180, but the motor did not respond properly and did not reverse, suggesting that the PWM on the pin was still running @~390Hz rather than giving a proper RC pulse.

A rundown of the 'ware: Macbook Pro running Mac OS 10.6.7 and Processing 1.5.1 Arduino Mega 2560 running StandardFirmata 2.2 Turborix EL 110A ESC fed for now by a 250W ATX PSU and controlling a small 12V Johnson motor for bench tests



What sketch do you have on the Arduino when this Processing application is running? Is it the ServoFirmata sketch? If not, why not?

Thanks for the advice Paul. I just tried ServoFirmata and the ESC worked fine.

Perhaps I should have clarified, but I've got several more actuators and sensors connected to the Mega that need to communicate with the computer, so ServoFirmata alone won't work. I know StandardFirmata supports servos since I can run the ESC from Firmata Test with StandardFirmata on the Arduino and all the sensors, etc. running, but for some reason I can't control servos from Processing.

So what I'd just love to know is if the Processing library is buggy or if I'm just using it wrong.

Here's my Processing test code (which incidentally controls the motor with a joystick rather than a mouse or arrow keys.) It works fine when [u]Servo[/u]Firmata is running on the Mega.

import procontroll.*;
import processing.serial.*;
import cc.arduino.*;

int escPin = 3;
ControllIO controll;
ControllDevice device;
ControllSlider xSlider;
float xVal;
Arduino arduino;

void setup(){
  controll = ControllIO.getInstance(this);
  device = controll.getDevice("Generic   USB  Joystick  ");
  xSlider = device.getSlider(0);
  arduino = new Arduino(this, Arduino.list()[0], 57600);
  arduino.pinMode(escPin, Arduino.SERVO);

void draw(){
  xVal = xSlider.getValue();