#include #include #include LiquidCrystal lcd(12,11,5,4,3,2); SoftwareSerial mySerial(6, 7); char phone_no[]="9131888122"; const int AOUTpin=0;//the AOUT pin of the alcohol sensor goes into analog pin A0 of the arduino const int DOUTpin=8;//the DOUT pin of the alcohol sensor goes into digital pin D8 of the arduino const int led=13;//the anode of the LED connects to digital pin D13 of the arduino const int buzz = 9; const int servopin = 10; Servo servo; int limit; int value; void setup() { lcd.begin(16,2); lcd.print(" DARUA DABOCHI "); lcd.setCursor(0,1); lcd.print("Give Breath Test"); delay(8000); mySerial.begin(9600); Serial.begin(9600);//sets the baud rate pinMode(DOUTpin, INPUT);//sets the pin as an input to the arduino pinMode(led, OUTPUT);//sets the pin as an output of the arduino pinMode(buzz, OUTPUT); servo.attach(servopin); lcd.clear(); } void loop() { value= analogRead(AOUTpin);//reads the analaog value from the alcohol sensor's AOUT pin limit= digitalRead(DOUTpin);//reads the digital value from the alcohol sensor's DOUT pin Serial.print("Alcohol value: "); Serial.println(value);//prints the alcohol value Serial.print("Limit: "); Serial.print(limit);//prints the limit reached as either LOW or HIGH (above or underneath) lcd.setCursor(0,0); lcd.print("BAC: "); lcd.print(value); lcd.print(" mg/L "); lcd.setCursor(0,1); delay(100); if (limit == LOW){ digitalWrite(led, LOW);//if limit has been reached, LED turns on as status indicator digitalWrite(buzz, HIGH); lcd.print("Alcohol Detected"); delay(3000); } else { lcd.print("!!NEUTRAL STATE!!"); digitalWrite(led, HIGH);//if threshold not reached, LED remains off digitalWrite(buzz, LOW); } switch(limit) { case LOW: SendMessage(); break; } if (value < 180) { lcd.print("YOU CAN DRIVE"); servo.write(90); delay(6000); servo.write(0); } else { servo.write(0); } } void SendMessage() { mySerial.println("AT+CMGF=1"); //Sets the GSM Module in Text Mode delay(2000); // Delay of 1000 milli seconds or 1 second mySerial.print("AT+CMGS=\""); // Replace x with mobile number mySerial.println(phone_no); delay(1000); mySerial.println("Driver of car GA05 p7834 found in drunken state.Please call him/her for the safety and help them.");// The SMS text you want to send delay(500); mySerial.println(char(26));// ASCII code of CTRL+Z }