This invention demonstrates how to connect a sonar distance sensor to your ThinkerShield. A sonar distance sensor sends out an ultrasonic sound which bounces off objects and returns to the sensor to tell how far away any objects are, very similar to echolocation in animals. Sonar sensors can be used for greater distances than infrared sensors but are less detailed.
This invention uses the NewPing library which is not automatically enabled when you install Arduino. You will need to install the NewPing library by going to Tools > Manage Libraries > search “NewPing” > click “Install”. For this invention I used alligator clip to female jumpers to attach the sensor. You may use normal alligator clips for this but you will need to bend the sensor pins to fit them neatly.
Please note – The NewPing library does not work if you are also using the buzzer.