Control the Basic ESC with a Potentiometer and Arduino

By DanielG

Introduction


This guide will show you how to use a potentiometer to control the Basic ESC. It builds from our Basic ESC R3 Example Code for Arduino so if you haven’t already, make sure to check that out first.

Parts and Tools

Main components used in this guide.

Main components used in this guide.

You Will Need

You will also need:

  • Arduino Microcontroller (This tutorial uses an Arduino Uno)
  • 10k ohm Potentiometer (center detent recommended)

Additional items:

  • 1 x USB A to B cable (for connecting to your Arduino to a computer)
  • 5 x Jumper Wires
  • Battery or Power Source for ESC/thruster
  • Arduino IDE

Wire Connections

All the components connected.

All the components connected.

Connecting the Potentiometer

  1. The potentiometer has 3 pins, connect one of the outer pins to 5V on the Arduino.
  2. Connect the other outer pin on the potentiometer to ground on the Arduino.
  3. Connect the center pin on the potentiometer to one of the analog in pins on the Arduino. In this example we’re using pin A0.
Potentiometer connected to the Arduino.

Potentiometer connected to the Arduino.

Connecting the ESC

  1. Connect the white signal wire from the ESC to digital pin 9.
  2. Connect the black (ground) wire from the ESC to a ground pin on the Arduino.
  3. Connect your thruster to the ESC by matching the green, white, and blue wires from the ESC to the green, white, and blue wires from the thruster.
  4. Connect the ESC to your power source.
ESC signal wires connected to the Arduino.

ESC signal wires connected to the Arduino.

ESC motor wires to thruster.

ESC motor wires to thruster.

Using the Example Sketch

  1. Connect your Arduino to the computer with the USB cable.
  2. Copy the code from the example sketch into your sketch in the Arduino IDE.
  3. esc-pot
  4. Make sure the potentiometer knob is turned to the center position.
  5. Upload the sketch to the Arduino.
  6. That’s it! If everything is working correctly you should hear the ESC arm after a few seconds. You can now control the throttle, forward and reverse, with the potentiometer.

Example Sketch

<br />
#include <Servo.h></p>
<p>byte servoPin = 9; // signal pin for the ESC.<br />
byte potentiometerPin = A0; // analog input pin for the potentiometer.<br />
Servo servo;</p>
<p>void setup() {<br />
servo.attach(servoPin);<br />
servo.writeMicroseconds(1500); // send "stop" signal to ESC. Also necessary to arm the ESC.</p>
<p>delay(7000); // delay to allow the ESC to recognize the stopped signal.<br />
}</p>
<p>void loop() {</p>
<p>int potVal = analogRead(potentiometerPin); // read input from potentiometer.</p>
<p>int pwmVal = map(potVal,0, 1023, 1100, 1900); // maps potentiometer values to PWM value.</p>
<p>servo.writeMicroseconds(pwmVal); // Send signal to ESC.<br />
}<br />

Troubleshooting

  • The ESC doesn’t arm after uploading the sketch:
    • If the Arduino was powered on before the ESC then the ESC might have missed the arming signal. Either restart the Arduino or return the potentiometer to the center position to send the correct arming signal.
Authors

DanielG

DanielG is a Technical Support Specialist at Blue Robotics.