#include <ESP32Servo.h>
#include "BluetoothSerial.h"
BluetoothSerial SerialBT;
Servo servo;
int servoPin = 27;
void setup() {
Serial.begin(115200);
// Initialize the Bluetooth service
SerialBT.begin("ESP32_Robotic_Hand");
Serial.println("The device started, pairing it with bluetooth!");
servo.attach(servoPin);
servo.write(90);
Serial.println("Servo initialized");
}
void loop() {
if (SerialBT.available()) {
char command = SerialBT.read();
// Checking what command is received (1 for up, 0 for down)
if (command == '1') {
servo.write(45);
Serial.println("Moving Arm Up");
} else if (command == '0') {
servo.write(135);
Serial.println("Moving Arm Down");
}
}
}