// EJEMPLO BASICO BLUETOOTH
#include "BluetoothSerial.h"
int LED1=25;
#if !defined(CONFIG_BT_ENABLED) || !defined(CONFIG_BLUEDROID_ENABLED)
#error Bluetooth is not enabled! Please run `make menuconfig` to and enable it
#endif
BluetoothSerial SerialBT;
void setup() {
Serial.begin(115200);
SerialBT.begin("CURSO_IOT_2023");
Serial.println("El ESP32 está listo, puedes emparejarlo mediante Bluetooth");
pinMode(LED1, OUTPUT);
}
void loop() {
if (Serial.available()) {
SerialBT.write(Serial.read());
}
if (SerialBT.available()) // si hay informacion disponible desde modulo
{
char DATO=SerialBT.read();
Serial.write(DATO); // lee Bluetooth y envia a monitor serial de Arduino
if (DATO=='A'){Serial.write("---------- ok-------");}
digitalWrite(LED1, !digitalRead(LED1));
}
delay(20);
}