Can I turn buzzer on and off using a single button android app via Bluetooth?

Hi, I am a newbie when it comes to Arduino. I wanted to ask if it is possible that when the android app alerts or alarms the buzzer will also be triggered then to turn it off, the alarm in the app should be turned off, and only then the buzzer will also stop. Bluetooth will be used to transfer data from android to Arduino.

I'm also using android studio btw, and thank you in advance to the people that will answer this.

yeah definitely! I'd recomend looking at this thread where I recently asked about how to parse serial data:

So let's say you set up a code that looks roughly like this:

char serialBuffer[64];
bool commandAvailable = false;

void setup() {
  // This is where you setup code goes
}

void loop() {

  readSerial(serialBuffer);

  if(commandAvailable&&!strcmp(serialBuffer, "BUZZ_ON"))
    digitalWrite(BUZZ_PIN, HIGH);
  else if(commandAvailable&&!strcmp(serialBuffer, "BUZZ_OFF"))
    digitalWrite(BUZZ_PIN, LOW);


}

void readSerial(char *s)
{
  //copy code from my thread over here,
  //this will copy whatever has been sent to your Arduino to serialBuffer[]
  //and will set commandAvailable true if ['\r' and '\n'] are received
}

the key difference however is that you will be reading your Bluetooth so you will need to adapt the code from the other thread depending on whether it is connected to RX and TX or two other digital pins

1 Like

This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.