Bluetooth ecs program


i really want to control an ESC with a bruschless motor with bluetooth.
I want to control the motor with an slider in an arduino app.
I already tried this code, but my motor doesn’t work.
Can someone help me?

#include <Servo.h>

Servo ESC;

char BluetoothData; // the data received from bluetooth serial link
int potValue = 0;

void setup() {

ESC.attach(9, 1000, 2000); // (pin, min pulse width, max pulse width in microseconds)
void loop() {

if (Serial.available()) {
BluetoothData =;
if (BluetoothData == ‘R’) potValue = Serial.parseInt(); //Read Red value

potValue = map(potValue, 0, 1023, 0, 180);
ESC.write(potValue); // Send the signal to the ESC


You might be better off to use a software serial port for the Bluetooth module and use the hardware serial for program upload, output and debug. Then use serial prints to monitor incoming data and program flow.

Read the forum guidelines to see how to post code and some advice on how to ask a good question.

What Arduino? Do you have a Bluetooth module? Which one? How is it connected?

What ESC/Motor and how is the ESC powered?

At the very least you need a Serial.begin() in there somewhere.


I have a hc06 and a arduino mega, the esc is a 80A and the motor is a kv 3300.
Bluetooth and esc is good connected. I tested the esc with a program without bluetooth.
And the module i tested with a LED. I added the Serial.begin and tried, but nothing works.
regards mathieu