Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Basics of controlling an electronic speed controller with an Arduino.
/* Created by Hersh Bhargava of H2 Micro (www.h2micro.com) */
#include <Servo.h>
Servo esc1; //Create a servo object to control a servo.
int xPotPin = 0; //Pins for analog potentiometers.
int esc1Value;
void setup() {
Serial.begin(9600);
}
void loop() {
esc1.attach(11); //Attach to the servo on the desired pin.
esc1Value = analogRead(xPotPin);
esc1Value = map(esc1Value, 0, 512, 0, 179); //Map values for the speed controller given the predetermined range.
esc1.write(esc1Value); //Write the values to the speed controller, thereby executing the speed change.
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.