Saipriya
Created September 4, 2024

Portable Wearable Navigation Device for Visually Impaired

One major problem for individuals with visual impairments is the inability to independently navigate through unfamiliar environments.

35
Portable Wearable Navigation Device for Visually Impaired

Things used in this project

Story

Read more

Code

Portable Wearable Navigation Device for Visually Impaired Individuals Using Ultrasonic Sensors and a

C/C++
1. Circuit Assembly:
o Connect the HC-SR04 ultrasonic sensor to the Arduino as described in the circuit diagram.
o Connect the vibration motor to the Arduino using a current-limiting resistor.
o Ensure all connections are secure and accurate.
2. Uploading Code:
o Open the Arduino IDE on your computer.
o Copy and paste the provided code into a new sketch.
o Connect the Arduino to your computer via USB.
o Select the appropriate board and port in the Arduino IDE.
o Upload the code to the Arduino.
3. Testing:
o Power the Arduino and observe the serial monitor for distance readings.
o Place objects at various distances from the sensor to test the vibration feedback.
o Adjust the nearThreshold value if necessary to suit your specific requirements.
// Define pins for the HC-SR04 ultrasonic sensor
const int trigPin = 9;
const int echoPin = 10;

// Define pin for the vibration motor
const int motorPin = 8;

// Define distance thresholds (in centimeters)
const int nearThreshold = 20;   // Distance at which the motor starts vibrating

void setup() {
  // Initialize serial communication
  Serial.begin(9600);

  // Set pin modes
  pinMode(trigPin, OUTPUT);
  pinMode(echoPin, INPUT);
  pinMode(motorPin, OUTPUT);

  // Ensure motor is off initially
  digitalWrite(motorPin, LOW);
}

void loop() {
  // Send a pulse to trigger the sensor
  digitalWrite(trigPin, LOW);
  delayMicroseconds(2);
  digitalWrite(trigPin, HIGH);
  delayMicroseconds(10);
  digitalWrite(trigPin, LOW);

  // Read the echo pin and calculate the distance
  long duration = pulseIn(echoPin, HIGH);
  int distance = duration * 0.034 / 2; // Speed of sound is 0.034 cm/us

  // Print distance for debugging
  Serial.print("Distance: ");
  Serial.print(distance);
  Serial.println(" cm");

  // Check if distance is within the threshold
  if (distance > 0 && distance <= nearThreshold) {
    // Turn on the vibration motor
    digitalWrite(motorPin, HIGH);
  } else {
    // Turn off the vibration motor
    digitalWrite(motorPin, LOW);
  }

  // Short delay before next reading
  delay(100);
}

Credits

Saipriya

Saipriya

1 project • 1 follower

Comments