bbc-microbit

Microbit can turn on a LED but not on motor


I use a Flame sensor (connect to pin0) to detect the fire and turn the pin1 to 1 when the sensor is nearby a candle, pin1 is connected to a LED, when sensor nearby a candle, the voltage from pin1 is 3.298V and the LED light up. I replace the LED with a small motor, the motor cannot be turned on and voltage is only 0.026V, the small motor can be turned on with 3V.

Below please find the code

basic.forever(() => {
if (pins.analogReadPin(AnalogPin.P0) < 20) {
    pins.digitalWritePin(DigitalPin.P1, 1)
} else {
    pins.digitalWritePin(DigitalPin.P1, 0)
}
})

How can I turn on a motor when a flame sensor is closed to a fire?

Best regards,

Kelvin


Solution

  • I read that the current limit on a micro:bit GPIO line is only 5mA and that the combined output for the GPIOs is 15mA. While this is just enough current to light an LED, this is not enough to power a motor. Power is current x voltage. One standard way to turn a motor or other device using a microcontroller is to connect the GPIO to the base (or the gate if using a field effect transistor, called a FET for short) of a transistor. A transistor can be thought of as a current amplifier. Applying a little current to the base allows a much larger current to then flow through the other two pins. The motor is powered through the transistor, not directly from the micro:bit. This allows a little current from the micro:bit to indirectly source a large current to the motor. The transistor will be connected to a power source, so the current to power the motor comes from the power source through the transistor, not through the micro:bit.

    You should be able to find a suitable design with a little searching through your favorite search engine. It is against SO recommendations to embed links in answers, as links can change or disappear, but the words 'arduino motor controller circuit' came up with some images and links that should help you.

    Good luck!