snehiludrhj
Published © GPL3+

Smart Glasses for Blind Prototype

This are the smart glasses which can tell you about how much far/near the object is in front of you. Helpful for blind people.

IntermediateFull instructions provided9,828
Smart Glasses for Blind Prototype

Things used in this project

Story

Read more

Schematics

Circuit Diagram #1

connecting arduino o ultrasonic sensor

Diagram #2

Mounting sensor on glasses

#3

#4

Code

Arduino IDE code

Arduino
const int trig = 2; //Trigger pin of ultrasonic Sesnor
const int echo = 3; //Echo pin of ultrasonic Sesnor
long time_taken;
int dist,distance;

void setup() 
{
  Serial.begin(9600);  //tells the arduino to get ready to exchange messages with the serial monitor  at a data rate of 9600 bits/sec.
  pinMode(trig, OUTPUT); //configures the specified pin to behave as output/input.
  pinMode(echo, INPUT);
}

/*###Function to calculate distance###*/
void calculate_distance(int trigger, int echo)
{
  digitalWrite(trigger, LOW);
  delayMicroseconds(2);
  digitalWrite(trigger, HIGH);
  delayMicroseconds(10);
  digitalWrite(trigger, LOW);

  time_taken = pulseIn(echo, HIGH);
  dist= time_taken*0.034/2;

}

void loop()
{
  calculate_distance(trig, echo);
  distance=dist; //getting distance of ultrasonic sensor
  Serial.println(distance);
  delay(1000);
}

Python3 code

Python
import serial #serial import for serial communications
import time
import pyttsx3
import speech_recognition as sr

engine = pyttsx3.init('sapi5')
voices = engine.getProperty('voices')
#print(voices[1].id)
engine.setProperty('voice',voices[1].id)

ArduinoSerial = serial.Serial('com3',9600) #Create Serial port object called arduinoSerialData


def speak(audio):
    engine.say(audio)
    engine.runAndWait()

def takecommand():
    #It takes microphone input from the user and returns string as output

    r = sr.Recognizer()
    with sr.Microphone() as source:
        print("Listening....")
        r.pause_threshold = 1
        audio = r.listen(source)

    try:
        print("Recogninsing....")
        query = r.recognize_google(audio, language = 'en-in')
        print(f"User said: {query}\n")

    except Exception as e:
        print(e)
        print("Say that again please...")
        return "None"
    return query

if __name__ == "__main__":
    while True:
     
        query = takecommand().lower()
        #logic for executing tasks based on query

        distance = int(ArduinoSerial.readline()) #read the serial data and print it as line
        dist=str(distance)
        print(dist)
        if "where is the object" in query:
            if (distance<20):
                    speak("StopStop, Close object in front.")
            
                
            elif (20<distance<60):
                    speak("object is quite a distance away.")
                    
            elif (40<distance<100):
                    speak("object is 1 meter away.")

            else:
                    speak("Object is far away.")
        
        else:
            print("nothing")
        

Credits

snehiludrhj

snehiludrhj

3 projects • 3 followers

Comments