Hello
My project is when tilt sensor is activated sender side will get power supply and hc-05 bluetooth master bluetooth will turn on and binds with slave. slave side bluetooth will be always on and it will be searching for bluetooth to bind.
i tried to activate the sensor and receiver side i have buzzer it got turned on when tilt sensor got activated. but the problem is buzzer is not turning off when i make tilt sensor off and master bluetooth is off.
can someone please check the code.
#define ledPin 6
int state = 0;
void setup() {
Serial.begin(38400);
pinMode(ledPin, OUTPUT);
digitalWrite (ledPin, LOW);
}
void loop() {
if(Serial.available() > 1){
state = Serial.read();
Serial.write(state);}
else {
Serial.write('0');
digitalWrite(ledPin, LOW);
}
if (state == '1')
{
digitalWrite(ledPin, HIGH);
}
else if (state == '0')
{
digitalWrite(ledPin, LOW);
}
}