Most of the code is directly from the OF Firmata example.
This is the code that moves the servo:
void ofApp::keyPressed (int key){
switch (key) {
case OF_KEY_RIGHT:
arduino.sendServo(9, 180, false);
break;
case OF_KEY_LEFT:
arduino.sendServo(9, 0, false);
break;
default:
break;
}
}
And this is the code for the PWM:
void ofApp::update(){
arduino.update();
if (!arduino.isInitialized()) return;
arduino.sendPwm(11, (int)(128 + 128 * sin(ofGetElapsedTimef())));
}