Introduction: Including a Proximity Sensor to the SSAD

This is an extension of the code, introduced in the Instructable "Vibrotactile Sensory Substitution and Augmentation Device" (https://www.instructables.com/id/Vibrotactile-Sens...). Additionally to analogue sensors, here, an example is given that illustrates how to include the input of ultrasonic proximity sensors to the SSAD prototype.

Supplies

  • Ultrasonic Proximity Sensor (HC-SR04)

Step 1: Wiring Proximity Sensor

Attach 2 ERM motors, one analogue sensor, such as an LDR, and an ultrasonic proximity sensor to an Arduino Uno with motorshield as illustrated in the picture.

  • Connect the echo pin of the proximity sensor to digital I/O pin 7 of Arduino.
  • Connect the trigger pin of the proximity sensor to digital I/O pin 11 of Arduino.

Step 2: Changes in the Code

Following changes have to be considered, when using a proximity sensor for the SSAD prototype:

(Find attached a file, where one proximity sensor is included already. Further, you can find a more detailed explanation of ultrasonic distance sensors here: https://howtomechatronics.com/tutorials/arduino/ul.... )

Two digital I/O pins are needed for getting the value of an ultrasonic distance sensor: The echo pin and the trigger pin:

int trigPin = 11;    // Trigger pin
int echoPin = 7;    // Echo pin

The minimumRange and maximumRange of the SensoryOutput are swapped: The lower the sensory input (distance), the stronger the vibration needs to be. Therefore, when defining SensoryOutput you firstly have to write the maximum value (e.g. 30000 for sensing a distance up to about 50cm) and then the minimum value (e.g. 150 for maximally vibrating at a distance of 2.55 cm and less):

SensoryOutput output1 = SensoryOutput(3000,150); 

The proximity sensor pins need to be setup in the setup() function:

pinMode(trigPin, OUTPUT); // Sets the trigPin as an Output
pinMode(echoPin, INPUT); // Sets the echoPin as an Input

Include the echoPin in the SensoryOutput object:

output1.include(echoPin);

The motor is setup and driven as explained in the main Instructable (https://www.instructables.com/id/Vibrotactile-Sens...).