Skip to content

Instantly share code, notes, and snippets.

@pingud98
Created February 27, 2014 23:33
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pingud98/9262003 to your computer and use it in GitHub Desktop.
Save pingud98/9262003 to your computer and use it in GitHub Desktop.
Robot arm manual control for processing
import cc.arduino.*;
import processing.serial.*;
Arduino arduino;
int servo1Pin = 9; // Control pin for servo motor
int servo2Pin = 10; // Control pin for servo motor
int servo3Pin = 11; // Control pin for servo motor
int penposn;
void setup(){
size (180, 180);
background(255);
arduino = new Arduino(this, Arduino.list()[1]);
arduino.pinMode(servo1Pin, Arduino.OUTPUT);
arduino.pinMode(servo2Pin, Arduino.OUTPUT);
arduino.pinMode(servo3Pin, Arduino.OUTPUT);
arduino.analogWrite(servo3Pin, 50); // the servo moves to the horizontal location of the mouse
penposn = 50;
}
void draw(){
arduino.analogWrite(servo1Pin, mouseX);
arduino.analogWrite(servo2Pin, mouseY);
if (mousePressed)
{
penposn = 23;
}
else
{penposn = 50;}
arduino.analogWrite(servo3Pin, penposn);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment