This commit is contained in:
commit
6783ee2423
1 changed files with 35 additions and 0 deletions
35
Miniarmcablibration.pde
Normal file
35
Miniarmcablibration.pde
Normal file
|
|
@ -0,0 +1,35 @@
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
|
||||||
Loading…
Reference in a new issue