Created
February 27, 2014 23:33
-
-
Save pingud98/9262003 to your computer and use it in GitHub Desktop.
Robot arm manual control for processing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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