I'm looking for somes idea to realize the joined image project.
Project description :
I connect an Arduino Uno R3 via USB to my computer (Windows 10).
I launch my browser and go to http://mysite.com/test, where lives a Javascript variable named in an original way : "myVariable".
I would like to introduce this Javascript variable to my arduino program, in order to do somes amazing stuff.
I would like to introduce this Javascript variable to my arduino program, in order to do somes amazing stuff.
Basically you can't. Code does not work like that.
What you have to do is to send a value to the Arduino and the Arduino reads it in the setup function and puts it into a variable. But you need the code at the PC end to send the variable a short time after you start the serial port.
Rather than access the website with your browser I reckon you need to access it with a program on your PC which can parse the webpage (screen-scraping is the common jargon) to get the value from the variable and can also communicate with your Arduino over the USB connection.
Of course if the server that produces the webpage is also on your PC the process could be much simpler - the server program could probably send the data to the Arduino. I do that using Python and the Bottle web framework
@Robin2: Yes the server of http://www.mysite/test is on my pc where Arduino is connected. Could you please list the name of elements used in your workflow ?
Your server is an Apache2 ? Your distribution is an Linux Debian 7 ? What is your Python version used ?
I developed it on Linux (one of the Ubuntu derivatives) but I suspect it will work on Mac and Windows if you change the serial port references. I use Python 2.7
The Python program uses the Bottle library to simplify the web programming. There is also some CSS and Javascript. It takes data from the browser and stores it in variables. There is a separate Python Thread for the communication with the Arduino. It takes data from the variables and sends it to the Arduino. It also listens for messages from the Arduino and stores them where they can be accessed by the web program. In practice it is two programs running in parallel and communicating through some common variables.