/** * Usage, according to documentation(https://www.firediy.fr/files/drone/HW-01-V4.pdf) : * 1. Plug your Arduino to your computer with USB cable, open terminal, then type 1 to send max throttle to every ESC to enter programming mode * 2. Power up your ESCs. You must hear "beep1 beep2 beep3" tones meaning the power supply is OK * 3. After 2sec, "beep beep" tone emits, meaning the throttle highest point has been correctly confirmed * 4. Type 0 to send 0 throttle * 5. Several "beep" tones emits, wich means the quantity of the lithium battery cells (3 beeps for a 3 cells LiPo) * 6. A long beep tone emits meaning the throttle lowest point has been correctly confirmed * 7. Type 2 to launch test function. This will send 0 to 180 throttle to ESCs to test them */ #include Servo motA; char data; /** * Initialisation routine */ void setup() { Serial.begin(9600); motA.attach(11, 1000, 2000); // 1000 and 2000 are very important ! Values can be different with other ESCs. displayInstructions(); } /** * Main function */ void loop() { if (Serial.available()) { data = Serial.read(); switch (data) { // 0 case 48 : Serial.println("Sending 0 throttle"); motA.write(0); break; // 1 case 49 : Serial.println("Sending 180 throttle"); motA.write(180); break; // 2 case 50 : Serial.print("Running test in 3"); delay(1000); Serial.print(" 2"); delay(1000); Serial.println(" 1..."); delay(1000); test(); break; } } } /** * Test function sending angle to the ESCs from 0 to 180 degrees */ void test() { for (int i=0; i<=180; i++) { Serial.print("Speed = "); Serial.println(i); motA.write(i); delay(200); } Serial.println("STOP"); motA.write(0); } /** * Displays instructions to user */ void displayInstructions() { Serial.println("READY - PLEASE SEND INSTRUCTIONS AS FOLLOWING :"); Serial.println("\t0 : Sends 0 throttle"); Serial.println("\t1 : Sends 180 throttle"); Serial.println("\t2 : Runs test function\n"); }