Mouse Move - Arduino Pro micro

Hello there, im coding a C# program that sends data to the arduino via COM ports.
I wanna to make arduino receive data X,Y as int (in a single send preferably) and then move the mouse to it.
I tried to pass as string, but it takes a long delay (to convert i guess). I need the faster way.
Any idea?

The code you have posted works perfectly here!
How large is the largest number you want to send?
What speed do you need?
Why pass a string for numbers? Surely you want to pass numbers?

for example, I have to send X: 1920 and Y: 1080 or X: 960 Y: 540 or X: 100: Y: 62.
and the speed which the mouse will move does not matter (if it does not have a very long delay), I can smooth it in the C # program ( i think)

I found this, but i dont know how to send this data.

byte bf[2];
void loop() {
  if (Serial.available() > 0) {
    Serial.readBytes(bf, 2);
    Mouse.move((char) bf[0], (char) bf[1], 0);
    Serial.println("X: " + (char) bf[0]);
    Serial.println("Y: " + (char) bf[1]);
    Serial.read();
  }
}

Im trying to send like this:

        {
            port = new SerialPort(name, 115200, Parity.None, 8, StopBits.One);
            port.Open();

            byte b = Convert.ToByte(32);

            WriteData(port, "" + b);
        } 
        public static void WriteData(SerialPort port, string data)
        {
            if (port.IsOpen) port.Write(data);
        }

This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.