Arduino servo project warning message

Hey everybody. I am new to arduino and I have some questions regarding a project im doing from the arduino playground. I followed the instructions on the playground link

My question is about a warning I got in processing. I opened procesing and pasted the code it told me to use in processing. It worked just fine. The servo moved along with my mouse. But at the bottom of the processing screen I got this warning even though it worked. Why do I have this warning? Also when I move the mouse right the servo goes left and when I move the mouse left the servo goes right? How can I reverse this?

WARNING: RXTX Version mismatch
Jar version = RXTX-2.2pre1
native lib Version = RXTX-2.2pre2
[1] “COM4”

The code is below.


  • Servocontrol (derived from processing Mouse 1D example.)
  • Updated 24 November 2007

// Use the included processing code serial library
import processing.serial.*;

int gx = 15;
int gy = 35;
int spos=90;

float leftColor = 0.0;
float rightColor = 0.0;
Serial port; // The serial port

void setup()
size(720, 720);
colorMode(RGB, 1.0);

println(Serial.list()); // List COM-ports

//select second com-port from the list
port = new Serial(this, Serial.list()[1], 19200);

void draw()
rect(150, 320, gx2, gx2);
fill(180 - (mouseX/4));
rect(450, 320, gy2, gy2);

void update(int x)
//Calculate servo postion from mouseX
spos= x/4;

//Output the servo position ( from 0 to 180)

// Just some graphics
leftColor = -0.002 * x/2 + 0.06;
rightColor = 0.002 * x/2 + 0.06;

gx = x/2;
gy = 100-x/2;


Also when I move the mouse right the servo goes left and when I move the mouse left the servo goes right? How can I reverse this?

By modifying the Arduino code. Try line 37. Or post it if you really want help.

what should I modify it to?

Did you use the Arduino code from the example without any modifications?

A servo doesnt go "right" or "left" - it turns. Look at it from the other side, and you see right/left makes no sense.

The line that commands the servo to be in a new postion servo1.write(v) could be modified to use the "opposite" angle - ie. servo1.write(180-v).

The Java warning is just that - a warning. It says you have several java versions on your machine, and one of the library units (the serial one) differs from the main one. If it was a serious error, you would get no output at all.

Thank you so much for ur help. I definetly will try your recomemdation.

That did it. It works. Now the question is how and why?

Now the question is how and why?

If a variable 'v' has a range 0..180, then 180 - v has a range 180..0.
That's arithmetic.