Cirkit Designer LogoCirkit DesignerYour all-in-one circuit design IDE Launch Cirkit Designer App

Arduino UNO-Based Drowsiness Detector with IR Sensor, Buzzer, LED Indicator, and Vibration Feedback

View and Edit Project In Cirkit DesignerImage of Arduino UNO-Based Drowsiness Detector with IR Sensor, Buzzer, LED Indicator, and Vibration Feedback

Circuit Documentation

Summary

This circuit is designed around an Arduino UNO microcontroller and includes a Sharp IR Sensor, a vibration motor, a buzzer, and a red two-pin LED. The Arduino UNO is used to read the analog value from the IR sensor and control the other components based on the sensor's readings. The circuit is likely intended for proximity detection or a similar application where the distance to an object is monitored, and feedback is provided via the buzzer, LED, and vibration motor.

Component List

Arduino UNO

Vibration Motor

Sharp IR Sensor

Buzzer

LED: Two Pin (red)

Wiring Details

Arduino UNO

Vibration Motor

Sharp IR Sensor

Buzzer

LED: Two Pin (red)

Documented Code

// Define pin connections
const int irSensorPin = A0;
const int buzzerPin = 7;
const int ledPin = 8;
const int vibrationMotorPin = 9;

// Define the number of readings to keep track of for averaging
const int numReadings = 10;
int irReadings[numReadings]; // Array to store the IR sensor readings
int readIndex = 0; // Index of the current reading
int totalIR = 0; // Sum of the readings
int averageIR = 0; // Average of the readings

void setup() {
  // Initialize the output pins
  pinMode(buzzerPin, OUTPUT);
  pinMode(ledPin, OUTPUT);
  pinMode(vibrationMotorPin, OUTPUT);
  
  // Start serial communication
  Serial.begin(9600);

  // Initialize all readings to 0
  for (int i = 0; i < numReadings; i++) {
    irReadings[i] = 0;
  }
}

void loop() {
  // Read the value from the IR sensor
  int irValue = analogRead(irSensorPin);

  // Update the readings array
  totalIR = totalIR - irReadings[readIndex];
  irReadings[readIndex] = irValue;
  totalIR = totalIR + irReadings[readIndex];
  readIndex = (readIndex + 1) % numReadings;

  // Calculate the average
  averageIR = totalIR / numReadings;

  // Print the average IR value to the serial monitor
  Serial.print("Average IR: "); Serial.println(averageIR);

  // Drowsiness detection based on average values
  if (averageIR < 300) { // Example threshold, adjust as needed
    // If the average IR value is below the threshold, activate the outputs
    digitalWrite(buzzerPin, HIGH);
    digitalWrite(ledPin, HIGH);
    digitalWrite(vibrationMotorPin, HIGH);
  } else {
    // If the average IR value is above the threshold, deactivate the outputs
    digitalWrite(buzzerPin, LOW);
    digitalWrite(ledPin, LOW);
    digitalWrite(vibrationMotorPin, LOW);
  }

  // Delay for a short period of time
  delay(100); // Adjust delay as needed
}

This code is designed to read the analog value from the IR sensor and calculate an average value over a series of readings. If the average value falls below a certain threshold, it activates the buzzer, LED, and vibration motor to alert the user. The delay at the end of the loop controls the rate at which the readings are taken.