Control a Gear Motor with an NPN Transistor and a Raspberry Pi Pico

Description: Since the GPIO pins on the Raspberry Pi Pico do not have enough power to turn on a Gear Motor, an NPN Transistor (2N2222) connected to 5V is used as a switch. A small amount of current sent when GPIO pin 1 is HIGH opens the NPN transistor to divert 5V of power to the Gear Motor. And when GPIO pin 1 is turned OFF, the NPN transistor closes the 5V of power.

Control a Gear Motor with an NPN Transistor and a Raspberry Pi Pico

Notes: The 1N4004 Rectifier Diode is connected to the GND and Power Pins of the Gear Motor to prevent any voltage spikes from back EMF.

Supplies:

1 – Breadboard 830 Points
1 – Raspberry Pi Pico
1 – NPN Transistor (2N2222)
1 – 5V N20 DC Gear Motor   >> Link <<
1 – 1N4004 Rectifier Diode   >> Link <<

Arduino Code:

#define motor 1

void setup() {

  pinMode(motor, OUTPUT);

}

void loop() {

  digitalWrite(motor, HIGH);
  delay(1000);
  digitalWrite(motor, LOW);
  delay(1000);

}

Comments

  1. Thanks for the input, if I want to do it with Thonny, is this code correct? (MicroPython)

    from machine import Pin
    import utime

    “name for Pin1″= Pin (1, Pin.OUT)

    while True:
    “name for Pin1”.value(1)
    time.sleep(10)
    ————————-
    Thank you very much for reading!

    Reply

Leave a Comment

+ 51 = 57