firmware Lorem

firmware Engineering Component of Our Project

All control logic was handled by an Arduino Nano microcontroller soldered to our protoboard. The controller is programmed in Arduino-C. It takes sensor inputs on the analog-input pins and controls the 'visualizations' via the PWM output pins.

Breathing Sensing and Display - Arduino

The Arduino reads the output of the breathing circuit through an analog read pin. The circuit outputs 5V while the fabric expands, 0V while it contracts, and a floating voltage between 0-5 while the fabric is still. The Arduino uses a cutoff value of 3V to set the output of the vibration motors and LEDs. If the read value is above 3V, the motors vibrate and the lights are on. Otherwise, they are both off.

Acceleration Sensing and Display - Arduino

The Arduino also uses a cutoff value for the accelerometer read out. If the read value is more than 0.7V away from 2.5 V, the lights in the spine turn on. The lights then stay on for a minimum of 15 Arduino cycles, where each cycle takes approximately 5 milliseconds. The implementation for this is that everytime the read accelerometer value is above the cutoff, a counter is set to 15. The counter is decremented every cycle. If the counter is greater than 0, the lights are on.

Distance Sensing and Display - Arduino

Our distance actuators have two modes: when the sensor detects an object and when it doesn't. If the sensor detects an object, the spikes on the shoulders continuously flutter up and down. If no object is detected, the spikes flutter slightly every 3 seconds, but not to the full height as they do when an object is detected.

Integration

Many of our actuations have built in time delays. However, using an actual Arduino delay statement would cause the rest of the actuators to lag and wait for the delay to finish. In order to avoid this issue, we wrote our code to ensure that each cycle ran as quickly as possible, and every sensor and actuator was read and written to every cycle. To incorporate timing in our components, we used modulus operations on the Arduino's system clock.


All final source code is available in our Github Repository. Git