#include SoftwareSerial BTSerial(10, 11); // RX, TX pins for Bluetooth communication int buzzerPin = 9; // Pin connected to the buzzer char command; // Variable to store the Bluetooth command void setup() { pinMode(buzzerPin, OUTPUT); // Set buzzer pin as output Serial.begin(9600); // Start serial communication BTSerial.begin(9600); // Start Bluetooth communication } void loop() { if (BTSerial.available()) { command = BTSerial.read(); // Read the Bluetooth command if (command == 'L') { digitalWrite(buzzerPin, HIGH); // Turn the buzzer on Serial.println("Buzzer ON"); } else if (command == 'R') { digitalWrite(buzzerPin, LOW); // Turn the buzzer off Serial.println("Buzzer OFF"); } } }