Hello I am Making a project involving the 'HC - SR04' ultrasonic sensor and the 'HC - 05' Bluetooth
module. I am having the following error in the code. When I didn't add the Bluetooth module in the code it was working just fine. Help will be appreciated.
CODE:
int Trig = 7;
int echo = 6;
int Led = 12;
long Time;
int distance;
int VALUE;
void setup()
{
pinMode(Trig,OUTPUT);
pinMode(echo, INPUT);
pinMode(Led, OUTPUT);
pinMode(11, OUTPUT);
}
void loop()
{
Serial.begin(9600);
if (Serial.available() > 0)
VALUE = Serial.read();
if(VALUE == '1'){
digitalWrite(Led, HIGH);
} else if(VALUE == '0'){
digitalWrite(Led, LOW);
}
}
digitalWrite(Trig, LOW);
delay(2);
digitalWrite(Trig, HIGH);
delay(10);
digitalWrite(Trig, LOW);
Time = pulseIn(echo, HIGH);
distance = Time*0.034/2;
if(distance <= 30){
digitalWrite(Led, HIGH);
delay(200);
digitalWrite(Led, LOW);
delay(200);
digitalWrite(Led, HIGH);
Serial.println("INTRUDER ALERT!!");
digitalWrite(11, HIGH);}
}
Thank you.