In this activity, you will learn how sound waves interact with objects, and with different types of materials. You and a friend can experiment with different items and materials to see how a bat’s echolocation interacts with them.
To get started, make sure that the ultrasonic sensor is appropriately connected to the Ardunio Uno.
To run the Arduino code, connect the Arduino’s Pin 12 to the sensor’s Trig Pin and connect the Arduino’s Pin ~11 to the sensor’s Echo Pin.
Clone or download the files. To download the files, click on the Clone or Download button. Then, download the files as a Zip and extract the Zip file.
- Download the Arduino IDE available at https://www.arduino.cc/en/Main/Software
- Install the IDE
- Open robo-bat-arduino.ino available in the robo-bat-arduino folder
- From the Tools menu, navigate to Port and select the serial port for the Arduino Uno
- Upload the code to your microcontroller by clicking on the Upload button
To make sure that the Arduino code is running, follow the following steps:
- Go to Tools
- Click on Serial Monitor If you see the arduino output, then you have successfully executed the code.
Now make sure that you close the Serial Monitor before running the processing code.
If you cannot see the output, go to the Prerequisites section and make sure that you have followed the instructions.
- Download the Processing IDE available at https://processing.org/download/
- Install the IDE
- Open robo-bat-processing.pde available in the robo-bat-processing folder
- Go to line 4 and make sure that ARDUINO_SERIAL_PORT_INDEX is has the correct value of the Arduino port based on your computer/laptop.
final int ARDUINO_SERIAL_PORT_INDEX = 7;
- Run the code
You should be able to see the following interface if you successfully execute the code. If not, please make sure that you have followed the instructions.