TALKING STICK FOR BLIND MAN ASSISTANCE

Photo of author

By Jackson Taylor

CIRCUIT

PROGRAM
unsigned int a=0,duration;
unsigned int b=0,duration1;
#define echoPin1 3 // Echo Pin1
#define trigPin1 4// Trigger Pin1
#define echoPin2 7 // Echo Pin2
#define trigPin2 8// Trigger Pin2
void setup()
{
 Serial.begin (9600);
 usinit();
}
void loop()
{
  us2();
uscheck();
}
void usinit(void)
{
pinMode(trigPin1, OUTPUT);
pinMode(echoPin1, INPUT);
pinMode(trigPin2, OUTPUT);
pinMode(echoPin2, INPUT);
pinMode(A0, OUTPUT);
pinMode(A1, OUTPUT);
pinMode(A2, OUTPUT);
pinMode(A3, OUTPUT);
pinMode(A4, OUTPUT);
pinMode(A5, OUTPUT);
pinMode(12, OUTPUT);
pinMode(13, OUTPUT);
}
void uscheck(void)
{
 digitalWrite(trigPin1, LOW);
 digitalWrite(trigPin1, HIGH); //sends signal 10 us to excite ultra sonic sensor
 delayMicroseconds(10);
 digitalWrite(trigPin1, LOW);
 duration = pulseIn(echoPin1, HIGH);//reads  duartion pulse in Microseconds
 a = duration/58;
 //Serial.println(a);//distance in CM
 //delay(50); //Delay 50ms before next reading.
  if ((10<a)&&(a<45))
 {
   digitalWrite(A5,LOW);
   delay(500);
   //Serial.println(“first”);
 }
else if ((45<a)&&(a<80))
 {
   digitalWrite(A4,LOW);
  // Serial.println(“second”);
    delay(500);
 }
 else if ((80<a)&&(a<115))
 {
   digitalWrite(A3,LOW);
    // Serial.println(“3rd”);
    delay(500);
 }
 else if((115<a)&&(a<150))
 {
   digitalWrite(A2,LOW);
 //   Serial.println(“4th”);
    delay(500);
 }
 else if ((150<a)&&(a<185))
 {
   digitalWrite(A1,LOW);
  //  Serial.println(“5th”);
    delay(500);
 }
 else if ((185<a)&&(a<220))
 {
   digitalWrite(A0,LOW);
    // Serial.println(“6th”);
    delay(500);
 }
 else if ((220<a)&&(a<255))
 {
   digitalWrite(13,LOW);
   //Serial.println(“7th”);
    delay(500);
 }
 else
{
 digitalWrite(13,HIGH);
  digitalWrite(A0,HIGH);
  digitalWrite(A1,HIGH);
  digitalWrite(A2,HIGH);
  digitalWrite(A3,HIGH);
  digitalWrite(A4,HIGH);
  digitalWrite(A5,HIGH);
}
}
void us2(void)
{
  digitalWrite(trigPin2, LOW);
 digitalWrite(trigPin2, HIGH); //sends signal 10 us to excite ultra sonic sensor
 delayMicroseconds(10);
 digitalWrite(trigPin2, LOW);
 duration1 = pulseIn(echoPin2, HIGH);//reads  duartion pulse in Microseconds
 b = duration1/58;
 Serial.println(b);//distance in CM
// delay(50); //Delay 50ms before next reading.
 if (b>190)
 {
    digitalWrite(12,LOW);
   Serial.println(“7th”);
    delay(500);
 }
 else
 {
    digitalWrite(12,HIGH);
 }
}