Control a motor using NPN transistor
You may have heard of the transistor, and you may have also learned that it is a major reason for the technological advancement we are now witnessing.
A transistor is a device that can be used as a switch. It is made from a special material and has at least three terminals for easy connection to an external circuit.
In this tutorial, we will learn how to use a NPN transistor to operate a DC motor. It will provide the motor with the necessary power.
The transistor has three pins: the base, the collector, and the emitter.
The base pin receives the control signal from the Arduino, while the emitter is connected to one of the motor wires to control it. The collector pin will be connected to the Arduino GND pin to complete the circuit.
NPN transistors are normally "off" (disconnected), unless power is applied to the base pin it will turn on.
That means when the base receives a high signal from the Arduino, your motor will be turned ON. But when the base receives a low signal, your motor will be turned OFF.
Getting the items
For this project you will need the following components you can buy them from our store.
Wiring it up
To set up the NPN transistor with the motor in the correct way, follow the instructions below. The image demonstrates how to connect the wires between the NPN transistor, the motor and the Arduino. Once they are connected to each other, connect the Arduino to your computer using the USB cable.
The function of this sketch is to control a DC motor using the Arduino with the help of the NPN transistor. The motor will be switched on for one second, then turned off, and the process will be repeated.
This code is basic and straightforward, and no libraries are required.
Let's put it to the test together!
Voltaat learn (https://www.voltaat.com/pages/voltaat-learn)
Link for full tutorial: https://bit.ly/3DyiYYw
Tutorial: Control a motor using NPN transistor
The function of this sketch is to control a DC motor using the Arduino with the help of the NPN transistor.
The motor will be switched on for one second, then turned off, and the process will be repeated
Connections from the NPN transistor:
• NPN emitter pin → Arduino GND pin
• NPN base pin (middle pin) → Arduino pin 3
• NPN collector pin → Motor first wire
Connections from the motor:
• Motor first wire → NPN collector pin
• Motor second wire → Arduino VCC pin (5V)
//Commands inside void setup run once
//Pin 3 is defined as an output
//Commands inside void loop run forever
//Turn the motor on
//wait for a second
//Turn the motor off
//wait for a second
Testing it out
After uploading the code to your Arduino board, you will observe the motor turning on and off every one second. You may modify this period by changing the value in the code for the delay function and trying out various outcomes.
What are your thoughts on the ideal application for this project?
Most of us are familiar with the switches used in household devices. A relay is a type of switch that can be connected to an Arduino or any other microcontroller.
In this tutorial, we will learn how to use a PNP transistor to operate a DC motor. It will provide the motor with the necessary power.
In this tutorial, we will learn more about bush buttons and how to use them. We'll use the push button in a simple project to control the Arduino's internal LED and print the current state of the button directly on your commuter.