#include <SoftwareSerial.h>
SoftwareSerial bluetooth(10, 11); // RX, TX
void setup() {
Serial.begin(9600); // Serial monitor
bluetooth.begin(9600); // Bluetooth module
pinMode(13, OUTPUT); // Output pin for controlling the switch
}
void loop() {
if (bluetooth.available()) {
char command = bluetooth.read();
// Check the received command
if (command == '1') {
digitalWrite(13, HIGH); // Turn on the switch
} else if (command == '0') {
digitalWrite(13, LOW); // Turn off the switch
}
}
}