Coding DJI Snail Motors and ESCs

Hey everyone,
I've been trying to use an arduino to control a DJI Snail Motor (with Snail ESC). The code below (which I created myself) works only half of the time. However, I was wondering if there was a more reliable way of coding the motors.
Info for the DJI Snail Motors can be found here - Snail - DJI
Specs can be found here - Snail - Product Information - DJI (scroll down on website to download manual)
And the code that I made is attached below:

int ledPin = 9;
int spd = 254;
int stp = 1; //change to "0" to stop motor

void setup() {

void loop() {
  analogWrite(ledPin, stp);
  for (int i = 0; i < 17; i++){
    analogWrite(ledPin, spd);

I have tried using code from other sites but they don't seem to work. If anyone has any ideas/advice that would be great!

What is your code trying to do? Why write(1) then instantly write(254) 18 times then go back round and write(1) again. I've assumed the motor is connected to 'ledPin' though why it's called that is beyond me. Is the ESC in standard mode or OneShot125 mode? If standard the analogWrite PWM frequency is awfully close to the 500Hz maximum allowed.

From the look of the specs using the Servo.h library would be better.


The code is just trying to run the motors on full throttle. I'm pretty sure the ESC is in standard mode (I haven't touched anything). I'm not too familiar with the Servo.h library, do you have any "sample code" you think will work?

ESC specs.


Max Allowable Voltage 17.4V
Max Allowable Current (Continuous) 30A
Max Peak Current(3 sec) 45A
Supported Throttle Signal Modes Regular/OneShot125
Max OneShot125 Signal Frequency 1kHz
Max PWM Signal Frequency 500Hz
Default PWM Output Signal Frequency 16kHz
Weight (Without Cables) 2.8g
Supported Battery 3S – 4S LiPo

What code have you tried?

Have you checked the ESC configuration as per the manuals.

Tom.. :grinning: :+1: :coffee: :australia:

Start by trying the Sweep example program from the IDE. Just replace the servo on pin9 with your ESC input. It should sweep slowly up to full speed and then sweep back down to zero over and over again.


Thanks for the program @slipstick!

So UPDATE: I have tested the motors with the program. They seem to work when the propellors are off - note, that the program only works only 70% of the time. Other times, the escs respond with rapid beeping or just become completely silent (they normally are constantly beeping).

When the propellers are on the motor, it seems to suddenly stop mid-program. It's like the power/current to the motor is suddenly cut off. I'm currently using a 12V DC supply ("wall plug" power adaptor) that's rated for 3000mA. I'm not too sure whether the motor is trying to draw too much current or the escs are preventing the draw of current from being too high (with the motor on, I would imagine more current would be required to operate)?

That power supply is tots inadequate. I have toys that draw multiples of 3 Amps in flight.

Time to start using a 3s Lipo with a high C rating for any serious use or testing.

I suggest a > 2000 mAh battery with 75/150 C. For starters.

Also: be careful. :wink:


So to actually "properly" or "theoretically" use a wall plug, I need it to be rated at 45A (which is.... yeah not gonna happen)?
Also, just wondering what the C rating actually means for Lipo batteries?
(thanks for the help.... soz I'm just a beginner at all this stuff so bear with me :slightly_smiling_face:)

You will surprise yourself…

So no, you don't need a 45 Amp supply. But 3 is your problem.

C rating gives an idea of the current capacity of the battery. Multiply the C rating times the capacity to get allowed current.

A 2000 mAh batt at 75 / 150 C would be good for 150 Amps.

The average current might be low, you need headroom for peaks.

Srsly, google it up here, you are literally going to be playing with fire or at least the potential thereof.


For a Lipo the C rating times the capacity (mAh number) tells you the theoretical maximum current you can get from the battery. So 2000mAh x 30C = 60A in theory. The catch is that many hobby batteries are seriously over-rated as you can tell if you understand the numbers E.g. a 150C battery used at that rate would be completely emptied in 20 seconds (never going to happen).

For your purposes I'd suggest 3S (11.1V nominal, 12.6V max) 3000mAh and at least 30C.


And that is seriously understated. :wink:

But either battery recommended would be way better than any wall wart or even a beefy bench supply.

Peak currents, and "peaks" can be broad and flat during flight, are quite high, lipos are uniquely useful in this use case because they can deliver huge currents.

Again, I recommend learning about the use and care of lipos, lithium polymer batteries, a mixed blessing if ever there was one.


This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.