Hello everyone!
Just made this account out of desperation really so I'm pretty new at this
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 , 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 .