Step 8Upload Code
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 Step | Download PDFView All Steps | Next Step » |
![]() |
Add Comment
|






















































