Alcohol Sensing Alert System, need help with coding

Hello everyone!

Just made this account out of desperation really so I'm pretty new at this :frowning:

My name is Tate, I'm pretty new to Arduino as a whole and I'm trying to make a system where there's an alcohol sensor (the MQ-3 to be more specific) attached inside a vehicle close to the driver's breathing area, if the driver happened to have alcohol in their breath, the system will lock the start of this vehicle by opening fuel pump with a relay, as well as alerting the user with a buzzer and a LED light that thee's alcohol in their breath.

So far I got this system working fine, although there's another case to consider that I haven't been able to make it work at all, where the driver can start drinking during the trip, in this case I want to alert the driver with the noise and light notification BUT stopping the vehicule midroad as this can cause an accident. So there'd be 3 cases overall for this system:

-The user is completely sober where the vehicle would start normally with nothing interfering

-The user has drank alcohol and tries to start the vehicle, the system will cut the fuel pump circuit with a relay preventing this action and there will be a LED turned on and a buzzer making a noise alerting the user.

-The user starts drinking during the road, the system only will turn on the buzzer and LED light but won't interfere with the fuel pump at all (kinda like when you don't put your seatbelt on).

#include <LiquidCrystal.h>
#define sensorDigital 2
#define LED 3
#define buzzer 4
#define sensorAnalog A0
const int rele = 7;
const int rs = 13, en = 12, d4 = 11, d5 = 10, d6 = 9, d7 = 8;
LiquidCrystal lcd(rs, en, d4, d5, d6, d7);
int valor_gas;
void setup() {
   lcd.begin(16,2);
   pinMode(rele, OUTPUT);
   pinMode(sensorDigital, INPUT);
   pinMode(sensorAnalog, INPUT);
   pinMode(LED, OUTPUT);
   pinMode(buzzer, OUTPUT);
   Serial.begin(9600);
}
void loop(){
  valor_gas = digitalRead(sensorDigital);
  int analog = analogRead(sensorAnalog);
  if(valor_gas==0)
  {
  digitalWrite(LED, LOW);
  digitalWrite(buzzer, LOW);
  lcd.setCursor (5,0);
  lcd.print("Sober");
  lcd. display();
  digitalWrite(rele, LOW);
  }
   else
  {
  digitalWrite(LED, HIGH);
  digitalWrite(buzzer, HIGH);
  digitalWrite(rele,HIGH);
  lcd.setCursor (5,0);
  lcd.print("Alert");
  lcd. display();
  delay(500);
  }
  delay(500);
  lcd.clear();
}

I've been looking all over for days but haven't found a solution yet and would really need a hand :face_with_diagonal_mouth:, the programming is showing me using an analog and digital input but it's using only the digital input cos so far I'm only simulating this and the MQ-3 library on proteus don't support the analog input lol, I'll attach a pic of my simulated project``

thank you so much in advance :black_heart: :black_heart:.

What you are trying is fine, as far as it goes. You really need to move the real world and use some real equipment. Right now you are basing the project on assumptions.
The real world driver would have a friend start the car and turn the heater/air conditioner on full blast and then get in and drive the car away.
Anyway, your problem remains that you have not included ANY way to tell if the car is even moving. And that depends on the actual vehicle you are designing for.

yup, you can also just wear a mask and avoid the system but it isn't intended to be a perfect system as far as it goes for the same reasons you mentioned haha.
Yes I can't think of a way to make the system tell if the car is already in motion or not bit wanted to make it in relation with the fuel pump somehow :face_with_diagonal_mouth:
thanks for the reply tho!!

Well, that certainly eliminates your product use in an electric vehicle.

Holding your breath until the engine starts is enough. Standing outside the car while turning the ignition key also works. If the drinker ends up having an accident after all, he will be charged not only with driving under influence, but also with illegal modification of the vehicle: even more trouble for him. The truth is: no device, electronic or otherwise, will ever save a man from his own stupidity.

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.