This week I built off my input deivce board -- a breakbeam sensor -- to work on creating an interface to go with it.
As a reminder, I created a breakbeam sensor for my pinball machine to determine when a game is complete. This board consists
of a IR LED and IR receptor.
I began by downloading Node.js to my computer, installing ws, websocket and serialport by running the following lines
of code within node
npm i serialport
npm i ws
npm i websocket
this allowed me to run websocket from a javascript code to create a visual interface for a user and to read in the information
from the serial monitor.
From there, I utilized Neil's method of reading in bytes from the serial monitor and projecting them out into my console.
I completed this by writing the following javascript file. Given the setup of the
javascript file, the serial numbers got converted to ASCII symbols so the numbers read in don't appear like that of the serial monitor.
However, to prove the system was actually reading in the correct thing, I included write the number 5 to the serial port from
my arduino code and showing that it would then populate into my terminal as demonstrated by the video above.
Unfotunately, I was unable to get websockets or ws functioning so I couldn't build the interface into a website.
In an ideal world, the website would have had a visual cue for when the beam broke by turning the screen red, flashing
an alarm or something of a similar nature.