Hello I'm new to Arduino.
I'm creating a project which is called "Illegal Parking Alarm". This project concerns about the illegal parking in streets which causes accidents or traffic. In our area, cars that are illegally parked will be clamped. I am concerned for both the authorities since they need to stroll around out area to check if there is illegal parking. So I've decided to create a project that will alarm the owner and send sms to authorities.
The main reason why am I here is because of the millis(); thingy. As I said, I am new to arduino. I wanted the alarm to start a timer when the sensor (ultrasonic) detected an obstacle so that it won't alarm immediately. I wanted it to wait for 5 mins before the alarm starts and message sends. The alarm works properly but I've never tried to put a timer. Also, the SMS is my concern. I am using SIM 800L and I am also new to it.
Please tell me where am I wrong or where are the parts I should fix. Thank you.
(I haven't inserted a program for millis since I don't know where to start)
#include<SoftwareSerial.h>
#define trigPin 9
#define echoPin 10
int Buzzer = 8;SoftwareSerial mySerial(2, 3);
int normalDistance;
boolean triggered = false;
long duration;
long distance;String number = "xxxxxxxxxx";
void setup() {
mySerial.begin(9600);
Serial.begin (9600);
pinMode(trigPin,OUTPUT);
pinMode(echoPin,INPUT);
pinMode(Buzzer,OUTPUT);long duration, distance;
}void loop() {
digitalWrite(trigPin,LOW);
delayMicroseconds(2);
digitalWrite(trigPin,HIGH);
delayMicroseconds(10);digitalWrite(trigPin,LOW);
duration = pulseIn(echoPin,HIGH);
distance = duration /58.2;if (distance >= 50||distance <= 0){
Serial.println("no object detected");
digitalWrite(Buzzer,LOW);
triggered = true;
}else {
Serial.println("object detected");
delay(10);
tone(Buzzer,400);
delay(500);
tone(Buzzer,800);
delay(100);noTone(Buzzer);
triggered = false;
}if (triggered){
mySerial.println("AT+CMGF=1");
delay(150);mySerial.println("AT+CMGS="+63"+number+""");
delay(150);mySerial.println("CAR DETECTED!CAR DETECTED!");
mySerial.println((char)28);
delay(150);
mySerial.write((byte)0x1A);delay(50);
mySerial.println();
}}