Smart Guide Stick

💻 Skill: Arduino Programming
📡 Skill: Sensor Interfacing
⚙️ Hardware: Arduino Uno
⚙️ Hardware: Ultrasonic Sensor
⚙️ Hardware: Buzzer
❤️ Healthcare
📦 Young Innovators Kit
Difficulty: Entry Level
⏱️ 30 mins
🔒

Wiring Diagram Locked

Create a free profile to unlock detailed component schematics and structural configurations for this kit.

Unlock Instantly
const int trigPin = 9;
const int echoPin = 10;
const int buzzerPin = 12;

long duration;
int distance;

void setup() {
  pinMode(trigPin, OUTPUT);
  pinMode(echoPin, INPUT);
  pinMode(buzzerPin, OUTPUT);
}

void loop() {
  // Trigger ultrasonic pulse
  digitalWrite(trigPin, LOW);
  delayMicroseconds(2);
  digitalWrite(trigPin, HIGH);
  delayMicroseconds(10);
  digitalWrite(trigPin, LOW);

  // Read echo time
  duration = pulseIn(echoPin, HIGH);
  distance = duration * 0.034 / 2;

  if (distance > 0 && distance < 50) {
    // 🔴 Continuous beep (very close)
    tone(buzzerPin, 1000);
  } 
  else if (distance >= 50 && distance <= 200) {
    // 🟡 Beeping (closer = faster)
    int gap = map(distance, 50, 200, 200, 800);

    tone(buzzerPin, 1000);
    delay(80);
    noTone(buzzerPin);
    delay(gap);
  } 
  else {
    // 🟢 No sound (far away)
    noTone(buzzerPin);
    delay(200);
  }
}
💻

Source Code Locked

Sign in to view, edit, and copy the full verification setup source code and config parameters.

Get Code Access