Microbit火焰传感器触发电机无法启动问题咨询及方案请求
Hey Kelvin, I see exactly what's going on here—your microcontroller's GPIO pin just doesn't have enough oomph to drive that motor directly, even though it works fine with an LED. Let's break this down and fix it step by step.
Why the motor isn't working
LEDs only draw a tiny amount of current (usually 5-20mA) to light up, which your pin1 can handle easily—hence the 3.298V reading. But small motors need way more current (often 100mA or more) to start spinning. When you hook the motor directly to pin1, the pin can't supply that current, so it gets "pulled down" to almost 0V, and the motor won't budge.
Fixes you can implement
Here are three reliable solutions, ordered by simplicity and common use:
1. Use an NPN transistor as a switch (most cost-effective)
This is the go-to method for driving small DC motors with GPIO pins. Here's how to wire it:
- Grab an NPN transistor like 9013 or S8050 (make sure it can handle your motor's current—check the datasheet!)
- Connect the base of the transistor to pin1 through a 1kΩ resistor (this limits current to the base, protecting your GPIO)
- Connect the collector of the transistor to one terminal of your motor
- Connect the other terminal of the motor to your 3V power supply
- Connect the emitter of the transistor to ground
- Critical: Add a 1N4007 diode in parallel with the motor, reversed (cathode to 3V, anode to ground) — this absorbs the "back EMF" voltage spike when the motor turns off, which can damage your transistor or microcontroller.
2. Use a relay module (easiest to wire)
If you don't want to mess with discrete components, a small relay module works great. The module handles the high current for the motor, while your GPIO just controls the relay's coil:
- Connect the relay module's VCC to 3V (or matching voltage), GND to your microcontroller's GND
- Connect the module's signal pin to pin1
- Wire your motor between the relay's NO (Normally Open) contact and 3V power, with the other motor terminal to ground
- When pin1 goes high, the relay clicks closed, powering the motor.
3. Use a dedicated motor driver chip (most reliable for larger motors)
If you need smoother control or have a slightly bigger motor, chips like DRV8833 or L298N (for larger motors) are perfect. These chips are designed to handle motor current and can even control direction if you need it later. Wire the control pins to your microcontroller, and power the motor from the chip's input (match the motor's voltage).
Modified code example (no big changes needed!)
The core logic of your code stays the same—you just need to control the driver circuit instead of the motor directly. Here's a MicroPython example (adjust for your language/board):
from machine import Pin import time # Initialize pins flame_sensor = Pin(0, Pin.IN) motor_driver_pin = Pin(1, Pin.OUT) while True: # Check if flame is detected (adjust the value if your sensor outputs low on detection) if flame_sensor.value() == 1: motor_driver_pin.value(1) # Trigger the driver to turn on motor else: motor_driver_pin.value(0) time.sleep(0.1)
Quick notes to avoid issues
- Make sure your motor's power supply can deliver enough current—if your 3V source is too weak, the motor still won't start even with a driver.
- Always share a common ground between your microcontroller, driver circuit, and motor power supply—this ensures proper signal levels.
- For the transistor method, double-check the transistor's pinout (base, collector, emitter) to avoid wiring it backwards.
内容的提问来源于stack exchange,提问作者Kelvin

