Quantcast
Viewing all articles
Browse latest Browse all 40524

Arduino / of0.9.0 / of0.8.4

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())));
}

Viewing all articles
Browse latest Browse all 40524

Trending Articles