- Raspberry Pi Pico
- HobbyWing SkyWalker 60A-UBEC
- FMS 70mm Ducted Fan
- 3S 1100mAh LiPo Battery
- Two jumper wires
- Breadboard
Connect the ESC's signal wire and ground wire to the Raspberry Pi Pico's GP15 and GND. Signal wire goes to GP15, ground wire goes to GND.
For ESCs with yellow/red/brown wires: brown is ground, yellow is signal, and red is the BEC 5V output. Do NOT connect the BEC 5V to the Raspberry Pi Pico — this may damage or destroy it!
For ESCs with white/red/black wires: black is ground, red is the BEC 5V output, and white is signal.
Connect the ESC's motor wires to the FMS 70mm EDF brushless motor. If the motor spins in the wrong direction, swap any two motor wires to reverse it. For indoor testing, reversing the motor direction is recommended — otherwise your keyboard might get blown off the desk.
Once all connections are confirmed, connect the LiPo battery to the ESC. You should hear the motor play a startup melody, followed by a beep every second — this means the ESC is waiting for a PWM signal.
Connect the USB cable to the Raspberry Pi Pico.
Codefrom machine import Pin, PWM
import time
# Hardware configuration
PWM_PIN = 15
MAX_THROTTLE_LIMIT = 0.15 # Limit to 15% throttle
# Initialize PWM at 50Hz
esc = PWM(Pin(PWM_PIN))
esc.freq(50)
def set_duty_us(us):
"""
Convert microsecond pulse width to Pico's 16-bit duty cycle (0-65535)
Formula: (us / 20000) * 65535
"""
duty = int((us / 20000) * 65535)
esc.duty_u16(duty)
def arm_esc():8
"""ESC arming sequence: send 1000us signal until ESC confirms"""
print("Arming ESC...")
set_duty_us(1000)
time.sleep(3) # Wait for startup melody to finish
print("ESC ready")
# Main logic
try:
arm_esc()
throttle_rate = 0
while throttle_rate < MAX_THROTTLE_LIMIT:
# Calculate target pulse width, e.g. 30% throttle: 1000us + (1000us * 0.30) = 1300us
target_us = 1000 + int(1000 * throttle_rate)
print(f"Throttle: {throttle_rate * 100:.1f}%...")
set_duty_us(target_us)
time.sleep(0.4)
throttle_rate += 0.005
set_duty_us(1000)
except KeyboardInterrupt:
# Force throttle to zero to prevent motor runaway
set_duty_us(1000)
print("\nEmergency stop")Open Thonny, paste the code into the editor, and save it. When prompted, choose "Raspberry Pi Pico" as the save location.
Running the ProgramHold the motor firmly, or secure it to a fixed surface. Once you are ready, press F5 to run the program. You will hear three beeps from the motor, after which it will begin to spin. It will stop automatically after a few seconds when the program finishes.


Comments