Anti-Sleep Glasses




Introduction: Anti-Sleep Glasses

About: I am an Electronics Engineer and hobbyist......I'm interested in work in robotics and automation, I make projects using Arduino and other hardware. I love to share things which I learn.

Hello all, I Hope you all are safe. I'm here with another project which you can build with very few components. In this instructables, I'm going to show you, how you can make an Anti Sleep Glasses by using Arduino and some very basic electronic components. This glasses alerts the driver whenever he is getting into sleep while driving the vehicle. since sleeping on wheels is dangerous sometimes it may converts into fettle accidents can leads to death. so to prevent such consequences of accident we can use this gadget to alert the driver when he feels drowsiness. So let's see & learn how we can make a simple Anti Sleep Glasses by our self..

Step 1: Let's Make It...!

Components Used:

Arduino Pro Mini X1 ______________________________ INDIA /

IR Sensor X1 ___________________________________ INDIA /

Transistor BC547 X1 _____________________________ INDIA /

Vibrator X1 _____________________________________ INDIA /

5 Volt Buzzer X1 ________________________________ INDIA /


4.7K x1

3.7V Battery X1 _________________________________ INDIA /

Glasses Frame X1 _______________________________ INDIA /

Just collect all the above Components.

let's understand how this project works?

Step 2: How It Works?

The working of this project is based on an Infra Red Sensor, This sensor is the heart of this project.

Let's take a look to the IR Sensor. In picture I shown a typical IR Sensor, basically it has a transmitter IR LED, A photo Diode, an Opp-amplifier IC and a potentiometer.

The photo diode is placed just next to the IR LED in such a way that it can not receive IR rays directly. Photodiode is sensitive to the IR radiation. It's cathode connected to the positive voltage i.e. 5volt and anode connected to the noninverting input of the Opp-amplifier which also get pulled down though the 10Kilo ohm resistor. Potentiometer in IR sensor is use to set the sensitivity distance of the sensor, it connected to the inverting input of the Opp-amplifier. IR LED continuously transmit the infra red rays and if any object comes in front of it, IR rays get reflected back and it received by the photo diode due to this change in IR radiation the voltage at the anode get change, the change in anode voltage is depend on the IR radiation received by the photo diode. More the IR radiation received grater will be the change in anode voltage. The output of the IR Sensor taken from the output of the Opp-amplifier. We can adjust the sensitivity distance by rotating the potentiometer on the sensor, we rotate the potentiometer that means we set a threshold voltage for the noninverting input of the Opp-amplifier. Whenever the voltage on the noninverting input is greater than the threshold voltage, the voltage on the noninverting input i.e. +ve voltage from the photodiode get forwarded and get the positive pulse at the output of the Opp-amplifier i.e. output of the sensor.

A typical IR sensors circuit diagram is attached check it for reference.

Let's see the main circuit diagram of the project. I connected a IR sensor to the Arduino Pro Mini board as Vcc of the sensor to the vcc of the Arduino Pro Mini, Ground to the ground and the output of the sensor to the Analog pin one (A1) of the Arduino Pro Mini. I used a 5 volt buzzer and a vibrator motor from the old cellphone for alerting. I connected both buzzer and vibrator motor in parallel and used an general purpose NPN Transistor (BC547) to drive them. Transistor's emitter connected to the ground and collector connected to the negative pin of the buzzer and vibrator motor. Positive terminal of vibrator motor and buzzer are further connected to the vcc of the Arduino Pro Mini. Base of the transistor connected to the pin D3 of the Arduino Pro Mini through the 4.7 kilo ohm resistor.

Step 3:

Here I didn't used any PCB for making the circuit, since it's circuit is not that much complex. I stick the sensor over the Arduino pro mini board using hot glue and solder it with short flexible wires. After next to it, I made a buzzer unit, in which the vibrator, buzzer and transistor is include, which I mount on left stick of glasses near ear. Also stick the battery on the same stick and mount an on off button near to the left eye. stick the sensor to the frame such as it will close to eye. the distance between the eye and the sensor will not more than 15 to 20mm .

Step 4:

After soldering and sticking all the components on frame, the anti sleep glasses is ready above are some pics of it. Now let's understand some settings and programming.

Step 5: Sensor Setting

It will be better if you do this before sticking the sensor on the frame, After connecting all the components power up it. Now set the the sensors sensitivity distance to minimum. About 10 mm or less..

Step 6: Programming.

Arduino pro mini dose not comes with any type of USB connector for programming, that's why it's hard for beginner to program it. But don't worry here I describing an easy way for uploading the program to Arduino pro mini. Take an arduino uno and remove its main IC i.e. AtMEGA328P. and then wire up it with arduino pro mini as shown in the above picture.

Arduino UNO Arduino Pro Mini

Vcc -------------------------------- Vcc

GND ------------------------------ GND

Rx --------------------------------- Rx

Tx ---------------------------------- Tx

Rst --------------------------------- Rst

After wiring connect Arduino Uno with computer using USB cable. Copy the following Arduino code and pest it in Arduino ide. Now goto tool menu and select board Arduino Pro mini, Again goto tool menu and select COM port. And Now click on upload Button. after uploading the program all done and its ready to play.

Let's Understand the code

The code is very simple, it's just for managing the delay for activating the buzzer after the sensor input

<p>int Sinput = A1;    // creating or assigning an int type variable for sensor input signal<br>int Buz=3;            // creating or assigning an int type variable for output buzz and vibrator</p><p>void setup()      /// in void setup we make the selected pins output or input.
</p><p>pinMode(Sinput, INPUT);  /// here it is sensors pin  so we are defining here that this pin is input pin 
pinMode(Buz, OUTPUT); /// here it is the pin used for transistor to control it,   so we are defining here that this pin is output pin</p><p>}
void loop()  
       delay (2000);    // we are waiting for two second after the input pulse from the sensor. if the pulse is for more than  2 second then buzzer get triggered
       digitalWrite(Buz, HIGH);
        if(digitalRead(Sinput)== HIGH)
               digitalWrite(Buz, LOW);

Step 7:

Watch Full video on this topic here on my YouTube channel ShubhamSuresh , stay tuned.

Also Thank You NextPCB:

This project is successfully completed because of the help and support from NextPCB. Guys if you have a PCB project, please visit their website and get exciting discounts and coupons.

Only 0$ for 5-10pcs PCB Prototypes:

Register and get $100 from NextPCB:

more info about PCB Assembly Capabilities:

Thank you!


Follow Me on Facebook || Instagram

Be the First to Share


    • New Year, New Skill Student Design Challenge

      New Year, New Skill Student Design Challenge
    • One Board Contest

      One Board Contest
    • Raspberry Pi Contest

      Raspberry Pi Contest



    Question 6 weeks ago

    Is this code will work because it's my project


    4 months ago

    Does IR harm the eyes?


    Reply 4 months ago

    yes, continuous exposure to IR for long time can harm your eyes. this project is just for educational purpose just for preoving the consept.