/* ULTRASONIC SENSOR LAB A NOTE about bats. Ultrasonic sensors use the same system as the modern Bat. Echolocation. Send out a sonic pulse (outside of human hearing range) Then wait for the echo to return. The longer the wait, the longer the distance. */ long reading; //Stores the value from the sensor void setup() { Serial.begin(9600); //Starts the Serial Monitor so we can see the values pinMode(3, OUTPUT); //Trip Pin: Sends out the echolocation pulse pinMode(2, INPUT); //Echo Pin: Listens for the echo } void loop() { //Sends out the sonic pulse digitalWrite(3, LOW); delayMicroseconds(2); digitalWrite(3, HIGH); delayMicroseconds(10); //Listens for the echo reading = pulseIn(2, HIGH); //Displays to the Serial Monitor Serial.println(reading); } /* What values do you get if your hand is in the sensor view range? Does the value change the further or closer you get Part 2 Add an LED or Piezo speaker to your breadboard. Add the code to activate the light and/or speaker if the sensor detects an object. */