Interface & Application programming

01

I followed Nadiah's instruction to connect serial on the web. I installed the SerialPort package, which is a Node.js package. I created a new folder in my localhost, set-up a new node project with npm init, which gives you a package.json file, and installed the SerialPort package with npm install serialport. So in order to run a script written with Node.js packages you run node index.js in the terminal, where index.js is the script that you want to run. Nadiah said that socket.io would be a good match for the SerialPort package. I installed the express and http packages and socket.io all of these with npm install.
I copied exactly same code from Nadiah's web-page. but when I run the node index.js, There were error messages. I tried to change some code. but still have a errors..
With TA's help, I now had the data being output in my terminal. I have a server.js file that contains the calls to create the web server, to open the socket on the server-side, and to use the serial port code:Then there is a simple index.html:And finally, there is a script.js that gets called within the index.html. This gets the parsed serial data and uses it to update a text value (this is called the client side, whereas the server.js script is called server side):
I then run node server.js in my terminal, and go to http://localhost:3000/ to see the result of the distance sensor in the browser:Now that I had the data coming into the browser, I could experiment with different browser-based packages/ways to visualize that one incoming number.