Bird
Raised Fist0
Drone Programmingprogramming~10 mins

ESC (Electronic Speed Controller) role in Drone Programming - Interactive Code Practice

Choose your learning style10 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to set the ESC throttle value to 50%.

Drone Programming
esc.set_throttle([1])
Drag options to blanks, or click blank then click option'
A0.5
B50
C1
D100
Attempts:
3 left
💡 Hint
Common Mistakes
Using 50 instead of 0.5 causes incorrect throttle setting.
2fill in blank
medium

Complete the code to initialize the ESC on pin 17.

Drone Programming
esc = ESC([1])
Drag options to blanks, or click blank then click option'
A15
B18
C17
D16
Attempts:
3 left
💡 Hint
Common Mistakes
Using the wrong pin number causes the ESC not to respond.
3fill in blank
hard

Fix the error in the code to arm the ESC safely.

Drone Programming
esc.arm([1])
Drag options to blanks, or click blank then click option'
A1
BFalse
C0
DTrue
Attempts:
3 left
💡 Hint
Common Mistakes
Passing 1 or 0 instead of True or False causes errors.
4fill in blank
hard

Fill in the blank to create a dictionary mapping motor IDs to ESC throttle values above 0.3.

Drone Programming
throttle_map = {motor_id: esc_throttle for motor_id, esc_throttle in motor_data.items() if esc_throttle [1] 0.3}
Drag options to blanks, or click blank then click option'
A>
B<
C==
D!=
Attempts:
3 left
💡 Hint
Common Mistakes
Using '<' or '==' will filter wrong values.
5fill in blank
hard

Fill all three blanks to create a dictionary of motor names in uppercase with throttle values above 0.4.

Drone Programming
result = { [1] : [2] for motor, [3] in motors.items() if [2] > 0.4 }
Drag options to blanks, or click blank then click option'
Amotor.upper()
Bthrottle
Dmotor
Attempts:
3 left
💡 Hint
Common Mistakes
Using motor instead of motor.upper() causes lowercase keys.

Practice

(1/5)
1. What is the main role of an ESC (Electronic Speed Controller) in drone programming?
easy
A. To control the speed and direction of the drone's motors
B. To capture images during flight
C. To provide GPS location data
D. To manage the drone's battery charging

Solution

  1. Step 1: Understand ESC function

    An ESC controls how fast and in which direction a motor spins.
  2. Step 2: Compare options to ESC role

    Only controlling motor speed and direction matches ESC's purpose.
  3. Final Answer:

    To control the speed and direction of the drone's motors -> Option A
  4. Quick Check:

    ESC = motor speed and direction control [OK]
Hint: ESC always controls motor speed and direction [OK]
Common Mistakes:
  • Confusing ESC with camera or GPS functions
  • Thinking ESC manages battery charging
  • Assuming ESC controls drone navigation
2. Which of the following is the correct way to set motor speed using an ESC command in drone programming?
easy
A. esc.speed = 'fast'
B. setSpeed(esc, 'high')
C. esc.setSpeed(100)
D. esc.set_speed(100%)

Solution

  1. Step 1: Identify correct syntax for setting speed

    The method esc.setSpeed(100) uses a numeric value and proper method call.
  2. Step 2: Check other options for syntax errors

    The other options use wrong syntax: strings instead of numbers, incorrect function calls, or invalid parameters like percentages.
  3. Final Answer:

    esc.setSpeed(100) -> Option C
  4. Quick Check:

    Correct method call with numeric speed [OK]
Hint: Use method calls with numeric speed values [OK]
Common Mistakes:
  • Using strings instead of numbers for speed
  • Wrong method names or syntax
  • Including percentage signs in parameters
3. Given this code snippet controlling an ESC:
esc.setSpeed(50)
esc.setDirection('reverse')
print(esc.getSpeed())
What will be the output?
medium
A. 'reverse'
B. 50
C. Error: Invalid method
D. 0

Solution

  1. Step 1: Analyze speed setting

    The speed is set to 50 with esc.setSpeed(50).
  2. Step 2: Understand getSpeed output

    esc.getSpeed() returns the current speed, which is 50.
  3. Final Answer:

    50 -> Option B
  4. Quick Check:

    Speed set to 50, getSpeed returns 50 [OK]
Hint: getSpeed returns last set speed value [OK]
Common Mistakes:
  • Confusing direction with speed output
  • Assuming getSpeed returns direction
  • Expecting error due to direction command
4. Identify the error in this ESC control code:
esc.setSpeed = 75
esc.setDirection('forward')
medium
A. Missing semicolon after setSpeed
B. Wrong direction value 'forward'
C. esc object not defined
D. Using assignment instead of method call for setSpeed

Solution

  1. Step 1: Check setSpeed usage

    esc.setSpeed = 75 assigns a value instead of calling a method.
  2. Step 2: Correct method call syntax

    It should be esc.setSpeed(75) to set speed properly.
  3. Final Answer:

    Using assignment instead of method call for setSpeed -> Option D
  4. Quick Check:

    Method call needed, not assignment [OK]
Hint: Use parentheses () to call methods, not = [OK]
Common Mistakes:
  • Assigning value instead of calling method
  • Assuming direction value 'forward' is invalid
  • Forgetting parentheses in method calls
5. You want to program an ESC to smoothly stop the drone's motor. Which sequence of commands is best?
hard
A. esc.setSpeed(50) esc.setSpeed(0)
B. esc.setSpeed(100) esc.setSpeed(0)
C. esc.setDirection('reverse') esc.setSpeed(0)
D. esc.setSpeed(0) esc.setDirection('stop')

Solution

  1. Step 1: Understand smooth stopping

    Gradually reducing speed from a moderate value to zero helps smooth stop.
  2. Step 2: Analyze options for smoothness

    esc.setSpeed(50) esc.setSpeed(0) reduces speed from 50 to 0, which is smooth. Others either jump or use invalid direction.
  3. Final Answer:

    esc.setSpeed(50) followed by esc.setSpeed(0) for smooth stop -> Option A
  4. Quick Check:

    Smooth stop = gradual speed decrease [OK]
Hint: Reduce speed gradually to zero for smooth stop [OK]
Common Mistakes:
  • Setting speed directly to 0 from max
  • Using 'stop' as a direction value
  • Reversing direction to stop motor
Recommended

Ready to prove it?

Pass the test and this pattern moves unknown strong while earning +1 Grip toward your certificate.

10 questions~5 mineasy hard