Communicate with PC Mousemovements

Hello guys, i want to communicate with my PC, so i just now how to do the Basic stuff, but if i want to receive values i had absolutly no idea how it works and i didnt found an example iam very new to c# and arduino aswell, maybe someone can help me with it and give me some examples how i can get the values from c# into my arduino.

My plan was for the first time to make mousemovents, i think it would be a good start for me.

Thanks for every answers.

You need windows code to send data over a communication link. If the communication link is USB then just use the serial COM port and send the bytes over, there are tons of tutorials for this, here is a random one

Once the data is sent you need to read it on the arduino side, I would suggest to study Serial Input Basics to handle this

Thanks but i cant find something like serialPort1.Write("MouseMoveX#", value);
and read it but i cant find an example or maybe iam just a bit blind.

I am unclear - Are you asking a c# question ? (It’s the arduino forun)

Yes i want to communicate with c# and my arduino wich works good but i want to change the values aswell wich wont work rn

The question probably belongs to a c# forum, but to read the mouse position (in screen coordinates ) you use the Cursor.Position Property

You extract the floating-point x- and y-coordinates to send them over the serial line. You either send them in binary (likely an IEEE compliant representation, mind endianness) or you send it over as ASCII after converting the float to a String ( ToString method).

yes but i think there is my Problem, that i dont know how i can send them to the arduino and put them into a variable that i can use for future things.

You have two tutorials in answer #2
Read and practice until it’s clear
(I’m not a Windows guy, the less I touch it the better I feel)

      while (Serial.available())
      {           
        data = Serial.readString();
        d1 = data.charAt(0);
        switch (d1){
        case 'S':

        {
        digitalWrite(13, HIGH);
        x=data.substring(1);
        servoval = x.toInt();
        delay(50);
        digitalWrite(13, LOW);
        break; 
        }           
       }

This works fine for me but it is too slow for this kind of project wich i plan.

marc113 == Flop | Save?

-jim lee

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