#include <BluetoothSerial.h>
BluetoothSerial SerialBT; // Objeto Blueteothserisl
const int ledPin = 2; // Pin pare ei LED
void setup() {
pinMode(ledPin, OUTPUT);
Serial.begin(115200); // Inicializa la comunicación serial por US6
SerialBT.begin("ESP32_LED_MECATRONICA"); // Inicializa la comunicación Bluetooth
}
void loop() {
if (SerialBT.available()) {
char command = SerialBT.read();
if (command == '1') {
digitalWrite(ledPin, HIGH); // Enciende el LED cuando recibe 'A'
SerialBT.println("LED Encendido");
} else if (command == '0') {
digitalWrite(ledPin, LOW); // Apaga el LED cuando recibe 'B'
SerialBT.println("LED Apagado");
}
}
}