Controlling ESC from Pro Micro

Hello all,

Sorry if this is posted somewhere else, but I've basically searched for the last few hours and have tried several things, but I can't get this to work.

My goal is to use a pro micro to control 4 brushless motors. I'm fairly new to Arduino, so I've been cruising the forums here trying to find a solution to my problem. I am using the following basic code:

// Running an ESC with a servo library // Code was found at

include "Servo.h"

Servo esc; int throttlePin = 0;

void setup() { esc.attach(9); }

void loop() { int throttle = analogRead(throttlePin); throttle = map(throttle, 0, 1023, 0, 179); esc.write(throttle); }

This does not cause the motor to spin, though. If I connect the motor directly to the signal from the RC receiver, it spins normally, so I know it's not a problem with the ESC or motor. Instead of the motor spinning, it just kind of shutters every second or two. I checked the signal going to my input pin on the scope, and I get what I expect: a square wave that varies in duty cycle as I change the throttle position. However, when I check the signal coming from the Arduino, I get a very strange square wave that is out of sync with the input signal, and completely random in duty cycle.

I've tried changing the input pin from the receiver, and I've tried piping the output to different pins, but I'm getting nowhere. Do I have a problem with my code, or is there something about the pro micro that is different from the boards on which people use this code? Any help would be greatly appreciated.


I've been reading about interrupts, specifically using them for this purpose, and was unsuccessful at getting any of the model interrupt codes to work for this application. I therefore decided to try my luck at writing my own code, starting with a very easy example (like my attempt at servo control above). I've managed to get a working motor with a solid signal using the following code:

// Trying my own interrupt code for the throttle control

// Define the input pin. Picking pin 7, which is attached to // interrupt 4 on the Arduino ProMicro


// Define a motor output pin


void setup() { // Set the input and output pins pinMode(THROTTLE_IN_PIN,INPUT); pinMode(THROTTLE_OUT_MOTOR1,OUTPUT);

// Attach the interrupt attachInterrupt(digitalPinToInterrupt(THROTTLE_IN_PIN),testFunction,CHANGE); }

void loop() {


void testFunction() { digitalWrite(THROTTLE_OUT_MOTOR1,digitalRead(THROTTLE_IN_PIN)); }

This seems completely different than the other examples I've found, but for some reason it works. I'm not sure if this will work in a bigger code, as I don't know if the digitalWrite() in testFunction will prevent other actions from occurring. My next step is to try this with an accelerometer code to test if that limitation exists, but I wanted to share this easy code in case there are others who are new to interrupts looking for simple examples.

This may be an ATmega32U4 / Servo library issue. Which version of the Arduino IDE are you using?