anti accident system using eye blink sensor

preview_player
Показать описание

Рекомендации по теме
Комментарии
Автор

For the people struggling with code here it is
#define Relay 13
#define buzzer A0
static const int sensorPin = 10; // sensor input pin
int SensorStatePrevious = LOW; // previousstate of the sensor

unsigned long minSensorDuration = 3000; // Time we wait before the sensor active as long
unsigned long minSensorDuration2 = 6000;
unsigned long SensorLongMillis; // Time in ms when the sensor was active
bool SensorStateLongTime = false; // True if it is a long active

const int intervalSensor = 50; // Time between two readings sensor state
unsigned long previousSensorMillis; // Timestamp of the latest reading

unsigned long SensorOutDuration; // Time the sensor is active in ms

//// GENERAL ////

unsigned long currentMillis; // Variabele to store the number of milleseconds since the Arduino has started

void setup() {
Serial.begin(9600); // Initialise the serial monitor

pinMode(sensorPin, INPUT); // set sensorPin as input
Serial.println("Press button");
pinMode(Relay, OUTPUT);
pinMode(buzzer, OUTPUT);
}

// Function for reading the sensor state
void readSensorState() {

// If the difference in time between the previous reading is larger than intervalsensor
if(currentMillis - previousSensorMillis > intervalSensor) {

// Read the digital value of the sensor (LOW/HIGH)
int SensorState = digitalRead(sensorPin);

// If the button has been active AND
// If the sensor wasn't activated before AND
// IF there was not already a measurement running to determine how long the sensor has been activated
if (SensorState == LOW && SensorStatePrevious == HIGH && !SensorStateLongTime) {
SensorLongMillis = currentMillis;
SensorStatePrevious = LOW;

Serial.println("Button pressed");
}

// Calculate how long the sensor has been activated
SensorOutDuration = currentMillis - SensorLongMillis;

// If the button is active AND
// If there is no measurement running to determine how long the sensor is active AND
// If the time the sensor has been activated is larger or equal to the time needed for a long active
if (SensorState == LOW && !SensorStateLongTime && SensorOutDuration >= minSensorDuration) {
SensorStateLongTime = true;
digitalWrite(Relay, HIGH);
Serial.println("Button long pressed");
}
if (SensorState == LOW && SensorStateLongTime && SensorOutDuration >= minSensorDuration2) {
SensorStateLongTime = true;
digitalWrite(buzzer, HIGH);
delay(1000);
Serial.println("Button long pressed");
}

// If the sensor is released AND
// If the sensor was activated before
if (SensorState == HIGH && SensorStatePrevious == LOW) {
SensorStatePrevious = HIGH;
SensorStateLongTime = false;
digitalWrite(Relay, LOW);
digitalWrite(buzzer, LOW);
Serial.println("Button released");


}

// store the current timestamp in previousSensorMillis
previousSensorMillis = currentMillis;

}

}

void loop() {

currentMillis = millis(); // store the current time
readSensorState(); // read the sensor state

}

mayankplayz
Автор

Sir can please give the code, that you have used

bablib
Автор

what sensor or module is this? where can I find it?

freeNode
Автор

Bro can u send full vedio of doing this

SSundaresanPillaiA
Автор

This ir sensor can do damage to eye or not

everythingisinfinity
Автор

Sir I am a student we are going to make our project in our school so can you please send me the code you have used? Please

a.sdharanidharan
Автор

Sir where, I can find your code, please help me

swastikswaroop
Автор

Baki video me tho ardunoo Nano use hua hai par Apne Arduino r3 use kiya

shubhambansod
Автор

Car company faltu features ki jagah ye ek feature de de to 90 % accident kam ho jaye..

mahendraify
Автор

Bro i need ur help. My circuit everything is ready. But problem is that when i close my eyes it doesn't work. So i asked help from of the engineering student he said u have to manage the sensitivity by using tester and moving the screw in eye blink sensor. So he says it depends on the light of the area is it?

alsondsouza