Skip to content

My Drone, My Definition

In this project, you will learn how to modify the drone’s code, including takeoff sound effects, motor speed, and LED lighting effects, to deeply understand the drone’s code structure.

  • C language arrays and macros
  • ESP-IDF project structure
  • Code compilation and flashing process
  • Buzzer, LED, and motor control
ItemQuantityNotes
ESP32-S3 Drone1Fully assembled
Computer1With VS Code + ESP-IDF plugin installed
USB Cable1For programming
  1. Extract starter_code.zip
  2. Open the folder with VS Code

Understand the project’s file organization:

FileFunction
main.cMain function, controls flight flow
buzzer.cBuzzer control, handles sound effects
led.cLED control, handles lighting effects
motors.cMotor control, handles speed

Open buzzer.c and find the tone array:

// Original code: takeoff sound
uint16_t tone[] = {440, 880, 440, 0}; // A4, A5, A4, silence

Change it to the first two lines of “Ode to Joy”:

uint16_t tone[] = {330, 330, 392, 392, 440, 440, 392, 0}; // E4, E4, G4, G4, A4, A4, G4, silence

Open motors.c and find the MOTORS_TEST_RATIO macro:

#define MOTORS_TEST_RATIO (uint16_t)(0.2*(1<<16)) // 20% speed

Change it to 30% speed:

#define MOTORS_TEST_RATIO (uint16_t)(0.3*(1<<16)) // 30% speed
  1. Press F1, type ESP-IDF: Build to compile the project
  2. Press F1, type ESP-IDF: Flash to flash to the drone
  1. Power on and listen if the takeoff sound has changed
  2. Press the test button to see if the motor speed is faster
  • Check if ESP-IDF environment is properly installed
  • Ensure there are no syntax errors in the code
  • Check USB connection
  • Confirm drivers are installed

Congratulations! You have successfully modified the drone’s code and understood the basic code structure. This is the first step to becoming a flight engineer!

In the next project, you will learn how to adjust PID parameters to make the drone fly more stably.