December 8, 2019 · Lab work

Serial Communication

Following on from my prototyping earlier in the week, I thought it to be a sensible idea to make use of my previous prototype to demonstrate some communication over Serial between Arduino and Processing.

Reconstructed MVP Prototype
Fritzing diagram of MVP Prototype

Although physically the same (the wiring is the same as last time, as can be seen in the above Fritzing diagram), I rewrote the prototype's Arduino code for this testing. My reason for doing this was that I found during some initial experiments, Processing couldn't handle the sheer amount of data that was being thrown at it. To simplify and reduce the data I was working with, I went back over the Capacitive Sensor documentation for Arduino and adapted some code [1] that would look for a simple threshold for each sensor. This proved to be more reliable in my experimentation throughout this task.

On the Processing side, I made a simple visualisation of my sensors using the rect() function, reading the incoming Serial data with some adapted code from a tutorial [2]. When the sensors weren't being touched, the visualisation looked like this:

Sensors when not being touched

When a sensor was touched, the associated segment of the visualisation would change colour, to black, as can be seen in this demonstration video:

Demonstration of data visualisation in Processing

The data being passed across the serial connection was a string of binary characters, in the format "0000". If the Arduino detected a touch on any of the sensors, it would send a 1 instead of a 0 in that position of the string. For example, if just the left-most sensor detected a touch, the string passed to Processing would be "1000", indicating to Processing to turn the left-most segment of the visualiser black. As can be seen in the video, the visualiser shows when 1 or multiple sensors are being touched at the same time. This is further demonstrated in the photos below:

Far left sensor pressed
All sensors pressed
Hand removed from sensors

For this particular demonstration, I used the Arduino to process the data, and just used the Processing side of things for the visualisation. I was somewhat worried about the loss of precision in my data if I was to try and pass raw data to Processing and then deal with processing the data there. In a future test, I may try passing off the data straight to Processing and experiment with that further.