Last active
November 21, 2016 13:24
-
-
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.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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