#include <BluetoothSerial.h>
BluetoothSerial SerialBT;
const int ledPin = 33; // Define el pin al que está conectado el LED en el ESP32
void setup() {
Serial.begin(115200);
SerialBT.begin("ESP32_Grupo_1"); // Nombre del dispositivo Bluetooth
Serial.println("Dispositivo conectado ");
pinMode(ledPin, OUTPUT);
digitalWrite(ledPin, LOW);
}
void loop() {
if (SerialBT.available()) {
char estado = SerialBT.read();
if (estado == '1') {
digitalWrite(ledPin, HIGH); // Encender el LED cuando se recibe '1' por Bluetooth
Serial.println("LED Encendido");
} else if (estado == '0') {
digitalWrite(ledPin, LOW); // Apagar el LED cuando se recibe '0' por Bluetooth
Serial.println("LED Apagado");
}
}
}