#include String text =""; char c ; int ALCO_IN = A0; int Speed; char Command; int drunk = 0; int LEDR = 46; int LEDB = 47; int LEDG = 49; int EnL = 34; //yellow int EnR = 41; //orange int Left = 10;//white int Right = 7;//grey int CURR_VAL; int CHECK; int flag = 0; const int rs = 12, en = 11, d4 = 5, d5 = 4, d6 = 3, d7 = 2; const int BUZZ= 8 ; LiquidCrystal lcd(rs, en, d4, d5, d6, d7); void setup() { // put your setup code here, to run once: //pinMode(DOUT, INPUT); //pinMode(MOTOR, OUTPUT); pinMode(LEDR, OUTPUT); pinMode(LEDB, OUTPUT); pinMode(LEDG, OUTPUT); digitalWrite(LEDR, LOW); digitalWrite(LEDG, LOW); digitalWrite(LEDB, HIGH); delay(1000); digitalWrite(LEDR, LOW); digitalWrite(LEDG, HIGH); digitalWrite(LEDB, LOW); delay(1000); digitalWrite(LEDR, LOW); digitalWrite(LEDG, HIGH); digitalWrite(LEDB, HIGH); digitalWrite(EnL,LOW); digitalWrite(EnR,LOW); Serial1.begin(19200); Serial2.begin(9600); lcd.begin(16,2); while(Serial2.available()<0){ lcd.print("Waiting for BT"); delay(1000); lcd.clear(); } lcd.print("Initializing...."); } void loop() { // put your main code here, to run repeatedly: //CHECK = digitalRead(DOUT); if (drunk == 0) { digitalWrite(EnL,HIGH); digitalWrite(EnR,HIGH); } Command = Serial3.read(); if ((Command >= "0") and (Command < "10" )) { Speed = Command; } if (Command == 'q') { Speed = 10; } if (Command == 'F') //forward { analogWrite(Left,Speed * 100); analogWrite(Right,Speed * 100); } if (Command == 'B') //backward { analogWrite(Left,0); analogWrite(Right,0); } if ((Command == 'L') or (Command == 'G' ) or (Command == 'H' )) //left { analogWrite(Left,Speed * 100); analogWrite(Right,0); } if ((Command == 'R') or (Command == 'I' ) or (Command == 'J' )) //right { analogWrite(Left,0); analogWrite(Right,Speed * 100); } if (Command == 'S') { analogWrite(Left,0); analogWrite(Right,0); } CURR_VAL = analogRead(ALCO_IN); lcd.setCursor(0, 0); if(drunk == 0){ digitalWrite(EnR, HIGH); digitalWrite(EnL, HIGH); } else{ digitalWrite(EnR, LOW); digitalWrite(EnL, LOW); analogWrite(Left, 0); analogWrite(Right, 0); } if(CURR_VAL > 725){ lcd.print("LIMIT REACHED, STOPING ENGINE..."); drunk = 1; Serial2.write("Send"); while(Serial2.available()>0){ c = Serial2.read(); text = text + c; } digitalWrite(BUZZ, HIGH); digitalWrite(LEDR, HIGH); digitalWrite(LEDG, LOW); digitalWrite(LEDB, LOW); if (flag == 0){ Serial1.write("AT+CMGF=1\r"); delay(500); Serial1.write("AT+CMGS=\"+919834778384\"\r"); delay(1000); //text = "hey hello bye \r"; Serial1.print(text); delay(500); Serial1.write(0x1A); flag++; } delay(2000); } else{ lcd.print("CURRENT ALCOHOL LEVEL IS:"); lcd.setCursor(0, 1); lcd.print(CURR_VAL); digitalWrite(BUZZ, LOW); } delay(1000); lcd.clear(); }