// by Joseph P Rampolla, Sept. 2022 #include <ESP32Servo.h> #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 Servo myservo; int servoPin = 13; BluetoothSerial SerialBT; char cmd[100]; int cmdIndex; int X; void setup() { Serial.begin(115200); SerialBT.begin("ESP32SineWaveServo"); //Bluetooth device name (any name) Serial.println("The device started, now you can pair it with bluetooth!"); myservo.attach(13); // servo pin on the ESP32 (servo needs its own 5-6 VDC power supply 1 amp myservo.write(132); // throttle at lowest setting, config slider 132 min to 11 max on RoboRemoFree app, ID "t" or any character cmdIndex = 0; X = 132; } void loop() { if (SerialBT.available()) { char c = (char)SerialBT.read(); if (X == 0) {(X = 132);}; if (c == '\r' || c == '\n') { cmd[cmdIndex] = 0; cmdIndex = 0; X = (atoi(cmd + 2)); if (X == 0) {(X = 132);}; // prevents servo jamming myservo.write(X); } else { cmd[cmdIndex++] = c; } } }The site owner is not and cannot be held liable for fire, electrical shock, property damage, bodily injury, loss of life, or accident of any kind caused by electrical circuits or any ideas, projects, techniques, or information contained on this site. The visitor assumes all risk and responsibility for any loss, injury, accident or damage arising from the use of information, ideas, techniques, projects, concepts, components, products, and circuits on this site.
Please refer to hobby reference materials for correct and safe use information regarding these and all electronic circuits. These diagrams are intended to explain how things were accomplished in theory, but it is the responsibility of the individual to locate precise information regarding electrical circuits, materials, ratings of components, etc. Do not attempt these hobby projects, or any electrical project, if you don't have the necessary skills and experience.