Problem with arduino.analogWrite() in Processing

I'm controlling 4 DC motors through Processing, using StandardFirmata on the Arduino.

  • I have checked the syntax of the Arduino library in Processing and I believe I have called the functions correctly.

Prior to uploading the StandardFirmata sketch, did you spend any time looking at it? In particular, the setPinModeCallback function is interesting. There are several cases - ANALOG, INPUT, OUTPUT, PWM, SERVO, and I2C.

You are calling using the pinMode method, which triggers the callback, to set the mode of the pin to OUTPUT.

Then, you are calling the analogWrite method for the pins. Look at the analogWriteCallback method. See how it checks the mode of the pin, and does nothing for INPUT, OUTPUT, and I2C pins (yours are OUTPUT).

If you want to use the pins for PWM, you need to call the pinMode function with a different value. I'm willing to bet you can figure out what the correct value is for PWM usage.

If not, look at that available options again - ANALOG, INPUT, OUTPUT, PWM, SERVO, and I2C. Perhaps you'll need to try them all, but I'm pretty sure that sooner or later you'll figure out the correct value for PWM pins.