Affordable smart stick for blind people (Arduino)


The reason I'm writing this post that I've seen many ideas like this but they are either prototype, too expensive or you can't find them in the market at all. So I thought how can I make it easy and affordable so that almost any one can make it and help hundreds and thousands of people (if someone start manufacturing this) who are visually impaired.

Let me tell you what this stick can do. It has two ultrasonic sensors. One pointing forward and another one downward. Each one has its own specific distance, and it will make a sound when it detects something in that range.

For example:
If forward facing sensor finds out any object within 60cm (you can extend it if you want) it starts making sound so that you know something is within 60cm. And if the downward facing sensor doesn't find anything after 65cm (you can extend it if you want) it starts making sound to let you know that there might be dip under your feet so you might take your next step carefully.

Let's see the sketch
int trigPin1 = 2;
int echoPin1 = 3;

int trigPin2 = 5;
int echoPin2 = 6;

void setup() {
  Serial.begin (9600);
  pinMode(trigPin1, OUTPUT);
  pinMode(echoPin1, INPUT);

  pinMode(trigPin2, OUTPUT);
  pinMode(echoPin2, INPUT);

}

void beepFirst(){
   // play a tone on pin 10
  tone(10, 340, 100);
  delay(30);
  // turn off tone function for pin 10:
  noTone(10);
}

void beepSecond(){
   // play a tone on pin 10
  tone(10, 240, 100);
  delay(20);
  // turn off tone function for pin 10:
  noTone(10);
}
//.............

void firstsensor(){ // This function is for first sensor.
  int duration1, distance1;
  digitalWrite (trigPin1, HIGH);
  delayMicroseconds (10);
  digitalWrite (trigPin1, LOW);
  duration1 = pulseIn (echoPin1, HIGH);
  distance1 = (duration1/2) / 29.1;

      Serial.print("1st Sensor: ");
      Serial.print(distance1);
      Serial.print("cm    ");

  if (distance1 >=65) {  // Change the number for long or short distances.
     beepFirst();
  } else {
    //-----
  } 
}

void secondsensor(){ // This function is for second sensor.
    int duration2, distance2;
    digitalWrite (trigPin2, HIGH);
    delayMicroseconds (10);
    digitalWrite (trigPin2, LOW);
    duration2 = pulseIn (echoPin2, HIGH);
    distance2 = (duration2/2) / 29.1;

      Serial.print("2nd Sensor: ");
      Serial.print(distance2);
      Serial.print("cm    ");
 
    if (distance2 <=60) {  // Change the number for long or short distances.
     beepSecond();
    }
 else {
      //-----
    } 
}

void loop() {
Serial.println("\n");
firstsensor();
delay(150);
secondsensor();
delay(150);
}

Few things we need to keep in mind here.
*Range of the sensors:
As you might already know that you can adjust the range of the sensors just putting the numbers (green highlighted) higher or lower.

*How to wire up the speaker for tone?
Well, just connect one wire to GND and one wire to pin 10 if you use the sketch above.

*How many times does it take the reading from the sensors?
Well, if it is in a state that it doesn't need to play any tones then it takes readings about 6 times in a second, you can make it bit faster or slower by changing the delay numbers (highlighted in yellow) at the bottom of the sketch.

*How to connect both ultrasonic sensors?
I've already written a post in detail about that, you can see it here.

Note:
I've noticed that if you get rid of the printing distance, it works even better. Although I'd recommend you to use the above sketch to adjust every thing first, because some people might need different length of stick. So after adjusting the distance by uploading the sketch above and seeing it on the serial monitor, once you are satisfied with it then get rid of the printing code or just use the sketch below.

The sketch below does nor print distances

int trigPin1 = 2;
int echoPin1 = 3;

int trigPin2 = 5;
int echoPin2 = 6;

void setup() {
 
  pinMode(trigPin1, OUTPUT);
  pinMode(echoPin1, INPUT);

  pinMode(trigPin2, OUTPUT);
  pinMode(echoPin2, INPUT);

}

void beepFirst(){
   // play a note on pin 10
  tone(10, 340, 100);
  delay(30);
  // turn off tone function for pin 10:
  noTone(10);
}

void beepSecond(){
   // play a note on pin 10
  tone(10, 240, 100);
  delay(20);
  // turn off tone function for pin 10:
  noTone(10);
}


void firstsensor(){ // This function is for first sensor.
  int duration1, distance1;
  digitalWrite (trigPin1, HIGH);
  delayMicroseconds (10);
  digitalWrite (trigPin1, LOW);
  duration1 = pulseIn (echoPin1, HIGH);
  distance1 = (duration1/2) / 29.1;


  if (distance1 >=65) {  // Change the number for long or short distances.
     beepFirst();
  } else {
//-----
  }  
}

void secondsensor(){ // This function is for second sensor.
    int duration2, distance2;
    digitalWrite (trigPin2, HIGH);
    delayMicroseconds (10);
    digitalWrite (trigPin2, LOW);
    duration2 = pulseIn (echoPin2, HIGH);
    distance2 = (duration2/2) / 29.1;

 
    if (distance2 <=60) {  // Change the number for long or short distances.
     beepSecond();
    }
 else {
//-----
    }  
}

void loop() {
 
firstsensor();
delay(150);
secondsensor();
delay(150);
}

I hope this will help someone. :)


2 comments:



Newly posted:
Reason why rich getting richer and poor getting poorer