Sukaran Gulati
Published © Apache-2.0

Life saver while driving

This project will detect if the person driving is drowsy/sleepy or not

IntermediateFull instructions provided2 hours632

Things used in this project

Hardware components

Arduino UNO
Arduino UNO
×1
Jumper wires (generic)
Jumper wires (generic)
×1
Thermopile IR Sensor, TS105-10L5.5mm
Thermopile IR Sensor, TS105-10L5.5mm
×1
9V battery (generic)
9V battery (generic)
×1

Software apps and online services

Arduino IDE
Arduino IDE

Hand tools and fabrication machines

Multitool, Screwdriver
Multitool, Screwdriver
Hot glue gun (generic)
Hot glue gun (generic)
Drill / Driver, Cordless
Drill / Driver, Cordless

Story

Read more

Schematics

Image

Circiut is defined in code

Code

Code

C/C++
//input pins
int a = 2; 
int b = 3;
int buzzer = 4

//values from sensors
int sens1;
int sens2;

//speed variable
int myspeed;

//time repeating variable
float mydelay = 500.0;     //delays between the loop ----- only this value is to be changed
float convert_to_secs = mydelay/1000.0;   //we convert microseconds in to seconds
                                          //because microseconds when represented in for loop
                                          //(like if repetition is done for 1000microseconds),
                                          //the for loop will run thousand
                                          //times. Therefore, we convert it
                                          //into 1/2 second ....(1)
float seconds = convert_to_secs*           // value in seconds (got from (1))
       /*1/convert_to_secs**/ 2*           // why????????????????????????????
                              2*           // reciprocal of this value is multiplied to it to make it 1 seconds
                 10;                       // repeat it for how many seconds
                           
                             
void setup() {
Serial.begin(9600);
Serial.print("convert to seconds");
Serial.println(convert_to_secs);
for(int p = 0; p <= 50; p = p + 5)
{
  myspeed = p;
  Serial.print("speed = ");
  Serial.println(myspeed);
}
  pinMode(a, INPUT);
  pinMode(b, INPUT);
  pinMode(buzzer, OUTPUT);
  Serial.println();         // Leave a blank line
  Serial.print("sec = ");
  Serial.println(seconds);

  pinMode(5, OUTPUT);
}
void loop() {
 A :digitalWrite(buzzer, HIGH);
 delay(100);
 digitalWrite(buzzer, LOW);
 delay(100);
 digitalWrite(buzzer, HIGH);
 delay(100);
 digitalWrite(buzzer, LOW);
 
  myspeed = 50;
  for(int k = 1; k <= seconds; k++)                                                                                                                                                                          
 {
 
            if(digitalRead(a) == 0)
            {
              sens1 = sens1 + 1;
              Serial.println("sens1");
            }
         
            if(digitalRead(b) == 0)
            {
              sens2 = sens2 + 1;
              Serial.println("sens2");
            }
            Serial.print("sens1 + sens2 = ");
            Serial.println(sens1 + sens2);
            delay(mydelay);
 }
 
          if(sens1 + sens2 <= 7)
            {
              Serial.println("");
             
              while(myspeed > 0)
              {
                myspeed = myspeed - 5;
                delay(50);
                Serial.print("speed = ");
                Serial.println(myspeed);
               
              }
            }
            else {
              goto A; 
            }
              for(int i = 1; i <= 5; i++)
              {
                for(int k = 1; k <= 3; k++)
                {
                  digitalWrite(buzzer, HIGH);
                  delay(80);
                  digitalWrite(buzzer, LOW);
                  delay(80);
                }
               
                for(int k = 1; k <= 3; k++)
                {
                  digitalWrite(buzzer, HIGH);
                  delay(200);
                  digitalWrite(buzzer, LOW);
                  delay(200);
                }
               
              }
           
           }

Credits

Sukaran Gulati

Sukaran Gulati

1 project • 1 follower
Started Coding at 13// 2 times US-China Young Maker Early Bird Award Winner // National Level Science competition participant// A Curious 🧠
Thanks to Sukaran Gulati.

Comments