#include BluetoothSerial SerialBT; // Объект Bluetooth const int ledPin = 2; // GPIO2 для светодиода void setup() { Serial.begin(115200); pinMode(ledPin, OUTPUT); // Инициализация Bluetooth с именем устройства SerialBT.begin("ESP32-LED"); Serial.println("Bluetooth готов к подключению!"); } void loop() { if (SerialBT.available()) { char command = SerialBT.read(); Serial.write(command); // Для отладки через монитор порта // Управление светодиодом if (command == '1') { digitalWrite(ledPin, HIGH); SerialBT.println("LED включен"); } else if (command == '0') { digitalWrite(ledPin, LOW); SerialBT.println("LED выключен"); } } delay(20); }