// Program for esp32 as bluetooth buffer // created by Jans Hendry // Universitas Gadjah Mada, Indonesia // Kamakura Node, Japan // fab academy MIT - 2022 // directive bluetooth serial #include "BluetoothSerial.h" BluetoothSerial SerialBT; // create an object char sign; // received char // variables const int sigToat = 4; // send signal to attiny3216 (digital pin) char von = 'on'; char voff = 'off'; void setup() { Serial.begin(115200); // start serial esp32 SerialBT.begin("ESP32 - Jans"); //Bluetooth device name // set pin as output pinMode(sigToat, OUTPUT); digitalWrite(sigToat, LOW); delay(500); // take a breath } void loop() { // tells esp32 that pairing is success if (Serial.available()) { SerialBT.write(Serial.read()); } // check whether serial bluetooth is also available if (SerialBT.available()) { sign = (char)SerialBT.read(); SerialBT.print("Received:");// write on BT app SerialBT.println(sign);// write on BT app Serial.print ("Received:");//print on serial monitor Serial.println(sign);//print on serial monitor delay(10); if(sign == von) { Serial.println("LED is ON:");//write on serial monitor digitalWrite(sigToat, HIGH);// turn the LED ON delay(20); } if(sign == voff) { Serial.println("LED is OFF:");//write on serial monitor digitalWrite(sigToat, LOW);// turn the LED off delay(20); } } delay(100); }