How To Make Almost Anything Neil Gershenfeld

JACKSON HOWELL

MIT Center For Bits And Atoms


INTERFACES

Fab labs share an evolving inventory of core capabilities to make (almost) anything, allowing people and projects to be shared. These are my projects.

Interface &
Application Programming -
Node.js Serialport
Node.js Websocket
p5.js visualizations

11.21.18

This week our individual assignment was: "write an application that interfaces with an input &/or output device that you made".

This was the week of the Thanksgiving holiday and I went home to visit my family in Virginia. Unfortunately, I forgot to bring the FTDI cable that I need to power my board and send serial messages to/from my computer. There was no time to order one, but I needed a way to begin software development nonetheless. So I began researching ways to simulate a mock device via Node.js serialport which you can install with npm install serialport. A mock device would be able to communicate with my computer via serial port and allow me to begin coding. Luckily I wasn't the first person in this predicament and there was some documentation floating around on this feature.

Once the mock device was successfully sending/receiving informaiton via serialport, I needed a way to get, or "broadcast", this information from the server side to the client side, aka the browser. This is done via websockets, npm install ws.

And, finally, once the websocket is successfully porting data from the server to the browser, I needed something to created a data-visualization, something that could "draw", like p5.js.

MORE ON P5 AND ALL OF THE OPTIONS FOR ACCELEROMTERS...

Download Files

Fig.1 Basic prototype with mock device, using node serialport, node websocket and p5. I am emitting a value that increases by 100, resetting at 1,0000. Meanwhile p5 outputs the value and redraws the text at the position of said value, from left to right.

Fig.2 index.js file, download here

Fig.3 index.html file, download here

Fig.4 testing my mock device

Fig.5 Can't get the parser to parse my buffer correctly

Fig.6 Having trouble parsing Niel's bit-shifting, C code into normal integers. Getting some strange console logs...

Fig.7 Finally parsed my values using using ByteLength!

Fig.8 Got the X,Y and Z data for the ADXL!