So I'm trying to get mouse input from a processing sketch and have my arduino move 2 servos based on mouseY and mouseX. THey are 2 mini TowerPro servos that should only be able to move 180 degrees, but by running my Processing sketch, the servo controlled by mouseY is fine, but the servo controlled by mouseX seems to not take any affect when mouseX is changed: it just keeps rotating, more than 180 degrees!? The two servos are externally powered with the right power source as well.
I have the Arduino board loaded with StandardFirmata and here's my Processing Sketch:
import processing.serial.*;
import cc.arduino.*;
Arduino arduino;
void setup() {
size(500, 500);
println(Arduino.list());
arduino = new Arduino(this, Arduino.list()[1], 57600);
arduino.pinMode(3, Arduino.SERVO);
arduino.pinMode(6, Arduino.SERVO);
arduino.servoWrite(3, 0);
delay(100);
arduino.servoWrite(6, 0);
delay(100);
}
void draw() {
background(constrain(mouseX / 2, 0, 180));
arduino.servoWrite(3, constrain(mouseX / 2, 0, 180));
delay(100);
arduino.servoWrite(6, constrain(mouseY / 2, 0, 180));
delay(100);
}
Thanks for the help!