Introduction: Haptic Distance Sensor
Handheld SONAR. This device will apply pressure to the wearer depending on the distance sensed which allows the wearer to virtually feel his or her surroundings without making physical contact.
This device is not a new idea. The only difference I wanted to make was modularity. In the past they were always built around a specific implementation such as a wrist mounted version or a belt mounted one. Since there is an endless variety of ways to make these devices I wanted to show you how easy it is so you can build the next version, which could be a hat, or a necklace, by simply attaching one to a cap or chain. This device can be used exactly as it is built too. In the process I also produced extremely minimalistic code but not before writing a monster.
This project uses a 3D printed enclosure to make a very streamlined and compact device but it's not vital. These could literally be made out of cardboard and still work, albeit not as sturdy.
While walking around my apartment and holding this in my palm I was able to find every doorway with my eyes closed. Had it been mounted on my body I wouldn't even need a hand to hold it.
For this build you will need:
- Ultrasonic distance sensor 1.00 USD
- Arduino Mini Pro 2.50 USD
- Programming board for Arduino Mini Pro 3.00 USD
- USB mini cable (these are very common) 1.00 USD
- Cables to connect boards 1.00 USD
- USB Power Cable 1.00 USD
- Power socket for cable 1.50 USD
- 9gram servo 2.00 USD
- USB power supply
- 26 AWG copper wire
- Solder
- Soldering iron
- Computer for programming
Optionally you can use a 3D printer for the enclosure in which case you may want:
- 2 @ 1 1/2" #10 bolts
- 2 @ matching acorn nuts
- 2 @ 1.6mm x 10mm bolts
- 2 @ 1.6mm nuts
- Screwdrivers
To add some finishing touches a nylon sleeve and bolt head caps dress it up a bit.
Step 1: Solder
A schematic for the wiring is in the photos for this step. It shows the servo wires running to a three position header which works fine but this takes up extra room in the enclosure so I eventually opted to simply cut the servo wires and solder them directly to the board. Both options work. The schematic doesn't explicitly show the data pins being soldered but please solder them at this step.
If changes are made for your build and different pins are used it will be necessary to change the code to reflect this. Any of the discrete pins may be used but I recommend against the data pins, 0 and 1. This could be built with an ATTiny85 chip since only three I/O pins are used.
Step 2: Program
The Arduino is programmed through an external programming board which connects through female↔female cables. Each board will have the data pins labeled and they will be in the same order so it is a matter of making sure each side is hooked up the same way. You may notice the transmit (Tx) and receive (Rx) pins are crossed from board to board but this this intentional since you want the receive pins to talk to the transmit pins so the cable bundle will go straight across.
If you have not already downloaded the Arduino IDE (Integrated Development Enviroment) please download and install this software on your computer.
Follow any instructions provided with your serial ↔ USB cable.
Code is shown at the end of this stepor it can be downloaded.
- Open or paste the code into the installed Arduino IDE.
- Select your serial port.
- Connect the Arduino
- Download the code.
unsigned long upperLimit = 15000;
void setup(){
pinMode(3, INPUT);
pinMode(4, OUTPUT);
pinMode(12, OUTPUT);
}
void loop(){
digitalWrite(4, HIGH);
delayMicroseconds(10);
digitalWrite(4, LOW);
int servoDelay = pulseIn(3, HIGH, upperLimit);
if((servoDelay < 110) || servoDelay > upperLimit){servoDelay = upperLimit;}
servoDelay = map(servoDelay, 110, upperLimit, 500, 2500);
digitalWrite(12, HIGH);
delayMicroseconds(servoDelay);
digitalWrite(12, LOW);
delay(15);
}
Step 3: Enclosure and Assembly
The first image is animated and shows all the changes the enclosure when through.
As mentioned earlier this project uses a 3D printed enclosure but anything you do to keep it all together is fine. Wood, plastic, epoxy, metal, fabric, and cement are just a few things. Like I also mentioned this is meant to be modular so anything you do to hack this project and make it your own just makes it more awesome.
A hemispherical cam is shown in the animated image. This half-circle is attached off center to the servo horn and applies varying pressure as the servo rotates. Again, this doesn't have to be made on a 3D printer. Just make sure you don't make it out of something sharp. A plastic lid from a food container would be a good example of something you could cut out to attach. It should be roughly 1.5" or 4cm in diameter. How far off center you attach it will determine how much the difference in pressure when measuring distances.
If you are going to build your own enclosure you don't need to do anything else with this step, just get building and you'll have yourself a handheld SONAR unit.
See the model in 3D space in your browser.
Files for Self Contained Haptic Distance Sensor:
The OpenSCAD files below are not necessary unless you want to change something
- OpenSCAD code. Download all files below
- Enclosure. Open this one
- Distance sensor footprint Support file
- Screw wing Support file
- Servo Horn Base Support file
- S symbol Optional
The halves of the printed enclosure are held together with the #10 bolts. The distance sensor is held in place with the 1.6mm bolts. The power socket is glued in place with the flat side resting against the wall. Small plastic nubs on the underside of the power socket can be trimmed or sanded off.
Step 4: About Me
Thank you for reading. The second image is animated to show the device from all around. It is connected to an ordinary USB phone charger which provides plenty of power.
If you improve this device, there's room, please tell us all how in the comments.
I run a blog where I talk incessantly about the things I build, including an unabridged version of this project that contains all the ways I screwed up and improved before publishing here. There are also other neat projects like a switchable voltage USB to serial adapter for programming Arduino minis and a Rotational Photography Rig which I'm planning to upgrade soon.