Introduction: Magdalena and Brenton INSTRUCTABLE
For this activity, Brenton and I used an ultrasonic sensor using sonar to determine the distance to an object. The basis of how this works is the transmitter or the (trig pin) will send a signal like a high frequency sound, then when the signal finds an object it is reflected and received by the transmitter (echo pin). Knowing the sounds velocity in the air, the time between the transmission and reception, allows us to calculate the distance to an object.
You will need an Arduino bread board , laptop, arduino ultrasonic sensor, three jumper wires, and circuit, usb for connecting the circuit to laptop where we put the code.
Step 1: Creating the Sonar
To create the sonar you will need the materials listed in the supplies section of the of the introduction. To begin you will use your laptop to create the code to make the ultrasonic sensor sonar work. To create the code you will first you create variables for the trigger and echo pin called trigPin and echoPin, respectively. The trigger pin is connected to digital Pin 9, and the echo pins is connected to digital Pin 10. You will also need to create the variable duration. It will save the time in between the emission and transmission of the code. In the setup() you will need to initiate it at 9600 so you will have a Serial.Begin(9600). You will also need a loop to initiate a LOW and High pulse value of 2 and 10.
Step 2: Setup
To create the setup, you will need the items listed in the supplies section of the introduction section. You will need to input the ultrasonic sensor onto the bread board. then you will need a jumper wire connecting the VCC from the sensor to the 5V on the circuit. Then a wire connecting Trig form the sensor to Pin 9 and one connecting Echo to Pin 10. Lastly, you will need to connect the GND from the sensor to GND on the circuit.
Step 3: Troubleshooting
You will need to run the code and test if it is accurate and works. The sensor will work to 10 feet with a total path distance of 20 ft and a limit of 20ms, thus the time should be set to above 20ms. Some other things to keep in mind are if the sensor cannot receive an Echo, then your OUTPUT can never go LOW.