Arduino to SVG

I'd like to have my Arduino Duo interacting with software on my PC which can draw objects, animate bitmaps etc. The Arduino responds to switches and potentiometers and the PC needs to be able to move or rotate objects on the screen according to what it receives from the Arduino. It's basically a train driving simulator.

Thanks

Arduino Duo

Do you mean Arduino Due? If so, check out how to use the Due as a HID; you can send keystrokes, mouse button clicks and mouse moves.

ronb1949: I'd like to have my Arduino Duo interacting with software on my PC which can draw objects, animate bitmaps etc.

I have been building a simple system for controlling a model railway. I made a simple track diagram with an SVG file that is displayed in a browser. I have clickable links where the turnouts are and when clicked the PC sends a message to the Arduino to operate a servo to move the turnout. At the same time the PC sends a message to the browser where the javascript causes the image to change so the user can see the new direction of the turnout.

The changes on-screen could just as easily be initiated by the Arduino sending a message to the PC which sends a message to the browser.

I only recently discovered how easily SVG images can be used in a web program. There is a lot of online info about that. I found this series very useful

...R

Hi Robin2

Thanks for your reply. How do you get the PC to send a message to the Arduino, and how does the PC send a message to the browser? Is the PC communicating with the Arduino via the USB port (Com3)?

BTW, my Arduino is a Uno. My Italian must be slipping!

Thanks again

ronb1949:
BTW, my Arduino is a Uno. My Italian must be slipping!

OK, then HID functionality is basically out of the Window (though you can hack an Uno to act as a HID).

Is the software on the PC existing software? If so, can you modify it? Or are you going to write it from scratch?

For communication between the PC and the Arduino have a look at the examples in Serial Input Basics - simple reliable ways to receive data. There is also a parse example to illustrate how to extract numbers from the received text.

The technique in the 3rd example will be the most reliable. It is what I use,

You can send data in a compatible format with code like this (or the equivalent in the PC programming language).

Serial.print('<'); // start marker
Serial.print(value1);
Serial.print(','); // comma separator
Serial.print(value2);
Serial.println('>'); // end marker

I use the Python Bottle web framework to create a simple web server on my PC.

And the code in this Python - Arduino demo is essentially the same as I use for communication with the Arduino. It is very similar to Serial Input Basics which was written more recently.

If the browser will not be making calls to the server as a result off user interaction then you can arrange for it to call the server at regular intervals to get the latest data. The w3schools website has a huge amount of tutorials on everything to do with web programming.

…R