Other Arduino Codes and Videos by Robojax

Control Servo Motor using ESP32 and Bluetooth ESP-SERV-BT-1

دروس آردوینو به فارسی

Control Servo Motor using ESP32 and Bluetooth ESP-SERV-BT-1

This video shows how to control position of Servo Motor using ESP32 Microcontroller to move it from 0° to 180° to any angle defined in bluetooth

We have 3 type of controling Servo Motor with ESP32

The link to use in the "preferences" of Arduino IDE for ESP32 board https://dl.espressif.com/dl/package_esp32_index.json Watch video for instructions.

Resources for this sketch

Code ESP-SERV2 controling Servo motor Using Potentiometer

 * Original Servo Library sourse: https://github.com/RoboticsBrno/ESP32-Arduino-Servo-Library
 * This is Arduino code to control Servo motor with ESP32 boards over bluetooth 
 * Watch video instruction for this code: https://youtu.be/5TlEgfFDrzI
 * Written/updated by Ahmad Shamshiri for Robojax Video channel www.Robojax.com
 * Date: Jan 05, 2019, in Ajax, Ontario, Canada
 * Permission granted to share this code given that this
 * note is kept with the code.
 * Disclaimer: this code is "AS IS" and for educational purpose only.
 * this code has been downloaded from http://robojax.com/learn/arduino/
 * Get this code and other Arduino codes from Robojax.com
Learn Arduino step by step in structured course with all material, wiring diagram and library
all in once place. Purchase My course on Udemy.com http://robojax.com/L/?id=62

Get early access to my videos via Patreon and have  your name mentioned at end of very 
videos I publish on YouTube here: http://robojax.com/L/?id=63 (watch until end of this video to list of my Patrons)

or make donation using PayPal http://robojax.com/L/?id=64

 *  * This code is "AS IS" without warranty or liability. Free to be used as long as you keep this note intact.* 
 * This code has been download from Robojax.com
    This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <https://www.gnu.org/licenses/>.
#include <Servo_ESP32.h>

static const int servo1Pin = 19; //printed G19 on the board

Servo_ESP32 servo1;

int servo1Angle =90;

int servo1AngleMin =0;
int servo1AngleMax = 180;

#include "BluetoothSerial.h"
#error Bluetooth is not enabled! Please run `make menuconfig` to and enable it

BluetoothSerial SerialBT;
String inData;

char receivedChar;// received value will be stored as CHAR in this variable

void setup() {
  SerialBT.begin("ESP32_Robojax"); //Bluetooth device name
  Serial.println("The device started, now you can pair it with bluetooth!");
	  //Servo control using ESP32 from Robojax.com


void loop() {

  //Robojax.com Servo with ESP32 Bluetooth
  if (Serial.available()) {
  while (SerialBT.available() ) {
    receivedChar =(char)SerialBT.read();
    inData += receivedChar;    
        if (receivedChar == '
    SerialBT.print("Received:");// write on BT app
    SerialBT.println(inData);// write on BT app   

    Serial.print("Received:");//print on Serial Monitor
    Serial.println(inData); //print on Serial Monitor     
    servo1Angle = inData.toInt() ;//convert it to integer  
    if(servo1Angle <=servo1AngleMax && servo1Angle >=servo1AngleMin)
      servo1.write(servo1Angle);//move servo to that angle   
           inData = ""; // Clear recieved buffer                    
        }//if (receivedChar

  }// while



If you found this tutorial helpful, please support me so I can continue creating content like this. support me via PayPal