3 Simple Ways to
Share What You Make

With Instructables you can share what you make with the world — and tap into an ever-growing community of creative experts.

PhotosPhotos

Share one or more photos of a project, recipe, or whatever you've made, quickly and easily.

Step by StepStep-By-Step

Share your step-by-step photos with text instructions of what you made so others can do it too!

VideoVideo

Share your how-to video. You'll need your embed code from a video site such as YouTube.

Ultrasonic Batgoggles

Step 8Upload Code

Upload Code
«
  • DSC03284.JPG
  • ArduinoMiniAndNGBreadboardPhoto.jpg
To upload the code, connect the 5v, ground, TX, RX pins on the PC board to those same pins on a chip removed Arduino board using some wires. Then connect the reset pin on the PC board to the where pin 13 would go in the DIP socket on the Arduino board. If this is confusing, please see the image which this replicates, except with an Arduino Mini. Next simply past the attached code in the Arduino editor (or brows to and open the .pde file in Arduino after downloading) and select the appropriate serial port and Arduino chip you are using and press the upload button.

The code works by playing beeps and then varying the inter-beep interval based on the distance measured by the sensor. So, if you are close to an object, the inter-beep interval decreases and the beeps occur faster. If you are far away from an object, the inter-beep interval increases so the bleeps occur more slowly. The controller checks the distance every 60ms, so the inter-beep interval changes dynamically. Currently it is scaled so 1 inch makes a 10ms difference in inter-beep interval. This makes the goggles work better for closer distances, but can be increased to work better for further distances. I tried an exponential scaling that increased the range at closer distances(using fscale but it didn't seem to change the response much in exchange for tons of code, so I scrapped it.) Since the time it takes to read the distance depends on the distance of the object being sensed (the sensor returns pulses up to 30ms long) the code measures the time it took to get the reading and compensates the delay times by that amount.

Every line on the code is commented and is (hopefully) self-explanatory.
« Previous StepDownload PDFView All StepsNext Step »

Pro

Get More Out of Instructables

Already have an Account?

close

All Steps Viewing
View all steps of an Instructable on the same page when you're a Pro Member.

Upgrade to Pro today!
10
Followers
1
Author:suneth