This document provides a detailed overview of a Safe Track Helmet System circuit. The system includes an Arduino UNO microcontroller, an MQ-3 alcohol sensor, a Triple Axis Accelerometer (ADXL335), a red LED, a Sim A7670c GSM module, a 5V battery, a resistor, and a buzzer. The system is designed to detect alcohol levels and sudden impacts, and it can send an SOS message in case of an emergency.
Arduino UNO
MQ-3 Breakout
Triple Axis Accelerometer (ADXL335)
LED: Two Pin (red)
Sim A7670c
5V Battery
Resistor
Buzzer
#include <SoftwareSerial.h>
// Pin Definitions
#define MQ3_PIN A0 // Alcohol sensor pin
#define BUZZER_PIN 4 // Buzzer pin
#define LED_PIN 5 // Red LED pin
#define XOUT_PIN A1 // X-axis of accelerometer
#define YOUT_PIN A2 // Y-axis of accelerometer
#define ZOUT_PIN A3 // Z-axis of accelerometer
// GSM Module Configuration
SoftwareSerial gsm(2, 3); // GSM module TX (D2), RX (D3 via voltage divider)
void setup() {
// Initialize pins
pinMode(MQ3_PIN, INPUT);
pinMode(BUZZER_PIN, OUTPUT);
pinMode(LED_PIN, OUTPUT);
pinMode(XOUT_PIN, INPUT);
pinMode(YOUT_PIN, INPUT);
pinMode(ZOUT_PIN, INPUT);
// Initialize Serial Monitor
Serial.begin(9600);
// Initialize GSM Module
gsm.begin(9600);
delay(2000);
Serial.println("Safe Track Helmet System Initialized");
}
void loop() {
checkAlcohol();
checkEmergency();
delay(500); // Adjust delay as needed
}
void checkAlcohol() {
int alcoholLevel = analogRead(MQ3_PIN); // Read alcohol sensor value
Serial.print("Alcohol Level: ");
Serial.println(alcoholLevel);
// Threshold for alcohol detection
if (alcoholLevel > 500) {
Serial.println("Alcohol detected! Activating buzzer...");
digitalWrite(BUZZER_PIN, HIGH); // Activate buzzer
delay(1000);
digitalWrite(BUZZER_PIN, LOW);
delay(1000);
} else {
digitalWrite(BUZZER_PIN, LOW); // Turn off buzzer
}
}
void checkEmergency() {
// Read accelerometer values
int x = analogRead(XOUT_PIN);
int y = analogRead(YOUT_PIN);
int z = analogRead(ZOUT_PIN);
Serial.print("X: "); Serial.print(x);
Serial.print(" Y: "); Serial.print(y);
Serial.print(" Z: "); Serial.println(z);
// Threshold for detecting sudden impact or tilt
if (x > 600 || y > 600 || z < 400) {
Serial.println("Emergency detected! Sending SOS...");
sendSOS();
blinkLED();
}
}
void sendSOS() {
gsm.println("AT+CMGF=1"); // Set GSM to Text Mode
delay(1000);
gsm.println("AT+CMGS=\"+1234567890\""); // Replace with the emergency contact number
delay(1000);
gsm.print("Emergency! The rider has met with an accident. Please help.");
delay(1000);
gsm.write(26); // ASCII code for CTRL+Z to send SMS
delay(5000);
}
void blinkLED() {
for (int i = 0; i < 10; i++) { // Blink the LED for better visibility
digitalWrite(LED_PIN, HIGH);
delay(500);
digitalWrite(LED_PIN, LOW);
delay(500);
}
}
This code initializes the Safe Track Helmet System, reads sensor values, and performs actions based on the readings. The system can detect alcohol levels and sudden impacts, and it sends an SOS message in case of an emergency.