We are about to switch to a new forum software. Until then we have removed the registration on this forum.
Hello,
I am trying to make Servo motor work using processing 1.0, I did everything what is necessary already, uploaded firmata code to the arduino board and it works perfectly with processing 2.0, the code where I can control servo motor with mouse, but when I put the code to the processing 1.0 the controlling becomes very poor. So I thought to write the code where I can control the servo motor without the mouse, but have no Idea how. I would appreciate any tips.
The code for controlling the motor with mouse is:
import processing.serial.*;
import cc.arduino.*;
Arduino arduino;
void setup() {
size(512, 200);
// Prints out the available serial ports.
println(Arduino.list());
// Modify this line, by changing the "0" to the index of the serial
// port corresponding to your Arduino board (as it appears in the list
// printed by the line above).
arduino = new Arduino(this, Arduino.list()[0], 57600);
// Alternatively, use the name of the serial port corresponding to your
// Arduino (in double-quotes), as in the following line.
//arduino = new Arduino(this, "/dev/tty.usbmodem621", 57600);
}
void draw() {
background(constrain(mouseX / 2, 0, 180));
// Output analog values (PWM waves) to digital pins 9 and 11.
// Note that only certain Arduino pins support analog output (PWM).
// See the documentation for your board for details.
arduino.analogWrite(9, constrain(mouseX / 2, 0, 180));
arduino.analogWrite(11, constrain(180 - mouseX / 2, 0, 180));
}
But what should be the void draw code just to tell the motor how much to move by the code, not the mouse.
Thank you Ignas
Answers
Why do you want to use Processing 1.0?
What if you reduce the frameRate() ?
One thing to add to @hamoid, why aren't you defining your servos as:
It is easier to work with servos and the arduino library this way. See this page: http://playground.arduino.cc/Interfacing/Processing#.UzHJx2dOWUk
DebianAddict