본문 바로가기

코딩 놀이

esp32 LED_BUILTIN OnOff(6)

보드에 장착된 Builtin LED GPIO 는 포트번호는 2를 OnOff 해봅니다.

아래 소스를 업로드 해봅니다.

#include "BluetoothSerial.h"

#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);
 pinMode(2,OUTPUT);
  SerialBT.begin("ESP32test"); //Bluetooth device name
  Serial.println("The device started, now you can pair it with bluetooth!");
}

void loop() {
  if (Serial.available()) {
    SerialBT.write(Serial.read());
   
  }
  if (SerialBT.available()) {
    Serial.write(SerialBT.read());
 
  }
  delay(20);
  digitalWrite(2,HIGH);
    delay(1000);
    digitalWrite(2,LOW);
    delay(500);

}