Skip to content

Instantly share code, notes, and snippets.

@keryil
Last active November 21, 2016 13:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save keryil/0f8e4bb00a92268381855fd1de0a4ce8 to your computer and use it in GitHub Desktop.
Save keryil/0f8e4bb00a92268381855fd1de0a4ce8 to your computer and use it in GitHub Desktop.
Arduino code for driving a brushless ESC based on values received over the serial port.
#include <Arduino.h>
#include <Servo.h>
static const int PROP_PIN = 9;
Servo brushless;
void setup() {
Serial.begin(9600);
brushless.attach(PROP_PIN);
brushless.writeMicroseconds(0); //set initial value, check your manual
Serial.println("Ready to receive commands");
}
void loop() {
if(Serial.available()) {
long value = Serial.parseInt();
brushless.writeMicroseconds(value);
Serial.print("Set PWM to ");
Serial.print(value);
Serial.println("ms");
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment