VCC → 5V on Arduino
GND → GND on Arduino
TRIG → Digital Pin 9
ECHO → Digital Pin 10
+ (Positive) → Digital Pin 8
– (Negative) → GND on Arduino
CODES ARE BELOW COPY AND PASTE ON ARDUINO IDE
#define trigPin 9
#define echoPin 10
#define buzzer 8
void setup() {
  pinMode(trigPin, OUTPUT);
  pinMode(echoPin, INPUT);
  pinMode(buzzer, OUTPUT);
  Serial.begin(9600);
}
void loop() {
  long duration;
  int distance;
  // Send trigger pulse
  digitalWrite(trigPin, LOW);
  delayMicroseconds(2);
  digitalWrite(trigPin, HIGH);
  delayMicroseconds(10);
  digitalWrite(trigPin, LOW);
  // Read echo
  duration = pulseIn(echoPin, HIGH);
  distance = duration * 0.034 / 2;
  Serial.print("Distance: ");
  Serial.print(distance);
  Serial.println(" cm");
  // If object is within 100 cm (1 meter), activate buzzer
  if (distance <= 100) {
    digitalWrite(buzzer, HIGH);
  } else {
    digitalWrite(buzzer, LOW);
  }
  delay(200);
}
Hey students! đź‘‹
Thanks for stopping by! This page is getting a fresh update and will soon be filled with amazing new science projects, DIY kits, and learning tools designed just for YOU.
We’re working hard to bring you:
🤖 Cool Arduino projects you can build yourself
đź’ˇ Fun and simple experiments to try at home or school
🛠️ DIY kits to learn electronics, coding, and sensors
🎓 Tips, tutorials, and guides to boost your STEM skills
🏆 Challenges and quizzes to test your knowledge
Whether you love robotics, want to learn coding, or just enjoy building things with your hands, there’s something exciting coming your way.
✨ Stay tuned and keep checking back—you won’t want to miss what’s next!
In the meantime, check out our YouTube channel for awesome tutorials, or visit other parts of the Kunal Science Project website for inspiration.
Keep creating. Keep learning. Keep exploring. 🔬🌟