vedrocks15
Published © GPL3+

Blind Man's Stick

The project makes use of an Arduino Uno and Nano to alert the blind man of an obstacle and a joystick to tell about the surroundings.

IntermediateProtip3 hours1,287
Blind Man's Stick

Things used in this project

Hardware components

Arduino Nano R3
Arduino Nano R3
×1
Arduino UNO
Arduino UNO
×1
Ultrasonic Sensor - HC-SR04 (Generic)
Ultrasonic Sensor - HC-SR04 (Generic)
×1
SG90 Micro-servo motor
SG90 Micro-servo motor
×1
Analog joystick (Generic)
×1

Story

Read more

Code

Arduino Uno

C/C++
For distance and buzzer
const byte trig=9,echo=8,buzz=2,check_pin=3;
long duration=0;
int distance=0;
void setup() {
  pinMode(trig,OUTPUT);                 //trigger pin for usonic
  pinMode(echo,INPUT);                  //echo    pin for usonic
  pinMode(buzz,OUTPUT);                 //buzzer pin
  pinMode(check_pin,INPUT);
  Serial.begin(9600);
}
int getdis()
{
 digitalWrite(trig,LOW);
 delayMicroseconds(2);
 digitalWrite(trig,HIGH);
 delayMicroseconds(10); 
 digitalWrite(trig,LOW);
 distance=pulseIn(echo,HIGH)*(0.034/2);
 return distance;
}
void loop() {
 if(digitalRead(check_pin)==HIGH)
 { 
  int di=getdis();
  while(di>=70)
   di=getdis();
  while(di<70 && di>50)
  {
    tone(buzz,3000,300);
    delay(3000);
    di=getdis();
  }
  while(di<=50 && di>30)
  {
    tone(buzz,3000,300);
    delay(1000);
    di=getdis();
  }
  while(di<=30)
  {
    tone(buzz,3000,300);
    delay(500);
    di=getdis();
  }  
 }
}

Arduino Nano

C/C++
Code for controlling servo
#include <Servo.h>
Servo serv;
const byte s=3,x=A0,ok_sw=2,check_pin=4;
int xmin=1023,xmax=0;
void setup()
{ 
 int swit=1;
//*****************************************************************************
 
 pinMode(x,INPUT);                     //X axis input of joystick
 pinMode(s,OUTPUT);                    //pin for servo signal
 pinMode(ok_sw,INPUT);                 //push_button on joystick
 digitalWrite(ok_sw,HIGH);             //push_button is an input button but we give it a reference point to understand wether on pushing to go to high or low(our case it goes to low)
 pinMode(check_pin,OUTPUT);
 digitalWrite(check_pin,LOW);
//*****************************************************************************
 
 serv.attach(s);                       //creating an object of class Servo
 serv.write(90);                       //calibrating servo to 90 degrees.
 
//*****************************************************************************
 
 Serial.begin(9600);
 
//**************Calibration___Routine******************************************
//The joystick is an actuator therefore the extreme end points of x values may keep on changing time to time
//Therefore through this routine we aim to calibrate the whole setup and find max and min x's analog values and that range would be mapped to (45 deg to 135 deg)
//45 to 135 deg is choosen because the servo I am using , can sustain the load greater than these angles.
 
 Serial.println("Please move your joystick to extreme left and press okay");
 while(swit==1)
 {
  int tmp=analogRead(x);
  if(xmin>tmp)                  //to get the min value before pressing button
   xmin=tmp;
  swit=digitalRead(ok_sw);
  Serial.println(swit);
  Serial.println(xmin);
  delay(100);
 }
 swit=1;
 delay(500);
 Serial.println("Please move your joystick to extreme right and press okay");
 while(swit==1)
 {
  int tmp=analogRead(x);
  if(xmax<tmp)                 //to get the max value before pressing button
   xmax=tmp;
  swit=digitalRead(ok_sw);
  Serial.println(swit);
  Serial.println(xmax);
  delay(100);
  digitalWrite(check_pin,HIGH);
 }
//Voice support will be added to make the blind guy understand where to move joystick
//*******************************************************************************
}
void rotate()
{
  int xval=analogRead(x);
  xval=map(xval,xmax,xmin,55,110);
  serv.write(xval);
  Serial.println(xval);
}

void loop()
{
 rotate();
 delay(300);
} 

Credits

vedrocks15
5 projects • 5 followers

Comments