What Will I Learn?
At the end of this tutorial:
♦ The readers will be able to create a mechanism in controlling the speed and direction of a dc motor using FET transistor and a pushbutton
♦ The readers will be able to know how the circuit works.
♦ Learn to apply the circuit in the future electronic projects
Introduction
Today, in this tutorial, we will create a mechanism in controlling the speed and direction of a dc motor using FET transistor and a pushbutton. The pushbutton will control either counter clockwise rotation or clockwise direction of rotation of the dc motor. While the transistor with the aid of a potentiometer controls the speed of the dc motor base from the programmed codes in the arduino uno
Requirements
Electronic Components
♦ Arduino Uno
♦ Pushbutton
♦ MOSFET
♦ Resistor
♦ BJT
♦ Relay
♦ Diode
♦ DC motor
♦ Battery
♦ Breadboard
♦ Connecting wires
Software
♦ Fritzing application
Difficulty
♦ Advance
Tutorial Contents
Using the fritzing software, we will create our circuit diagram, arduino codes and prototype using the breadboard
Part I. Schematic Diagram
So first let us construct our circuit diagram.
Select the electronic components needed for the circuit in the fritzing library. We need 1 arduino uno, 2 pushbutton, 2 BJT transistor, 1 MOSFET, 3 resistors, 1 diode , 1 battery, 1 dc motor, 1 potentiometer and 2 5V relay.
Arrange the components before constructing the circuit.
In arranging the components, place all the components for the input side (left side) of the arduino and the components for the output side (right side).
In this tutorial the input components will be the potentiometer that will control the speed of the motor and two pushbuttons that control the direction of rotation either clockwise or counter clockwise. The rest of the components are for the output side.
Now let us construct our circuit diagram.
To be able to control the speed of the dc motor, we need the input signal from the potentiometer. So we only need 1 input pin of our microcontroller. For this tutorial, I will use the analog pin number 2. Our potentiometer has three terminals, one for the source voltage, one for the output and a ground.
Then to control the direction of rotation, our two pushbuttons will be connected to two inputs of our microcontroller, for clockwise and counter clockwise direction. In this tutorial, I will use the pin A0 and A1 for the two input pushbuttons.
At the output side of our circuit, we need to connect a two amplifier circuit to the two relays then the output these relays will be connected to the dc motor.
The two output pins, 12 & 13 will be connected to the transistor. Then the amplified output at the collector terminal will be connected to the input of the two relays as you can see in the figure below.
The output of the two relays will be connected to the dc motor and to the battery. Then the other terminal of each relay will be connected to the drain terminal of the MOSFET.
Then the output pin 11 will be connected to the gate terminal of the MOSFET and a diode must be connected in parallel with the drain to source connection.
Here is our final circuit diagram.
When you want to control the direction of rotation of the dc motor, just select between the two pushbuttons. And if you want to control the speed of the dc motor, just use the potentiometer by rotating or adjusting it.
If the desired speed is needed, upon adjusting the potentiometer, an output signal at pin 11 is being control as it flows through the gate terminal of the MOSFET. The use of the diode is to allow current to flow in one direction only to avoid damaging the MOSFET.
If you want to change the direction of rotation, just press on the pushbutton intended for the clockwise rotation of the motor. There is an output signal that will flow through the amplifier circuit to be amplified. Then this amplified output is then fed to the input of the relay. If the relay triggers, it will drive the dc motor in the clockwise direction.
The other pushbutton is for counter clockwise direction of rotation of the dc motor. The polarity is being reversed.
Then for the speed control, the moment you adjusted the potentiometer, the current flows through the gate terminal is being controlled that is why the output signal at the drain terminal of the MOSFET is also controlled and because this is being applied to the dc motor, the dc motor will be slowed down.
Part II. Code
Now let us do programming of our Arduino uno.
Click on code to start.
We declare that the input pins of the two pushbuttons are analog pin 0 & 1 and for the potentiometer is pin 2. The output pins will be the pin 11,12 & 13.
int clockwisePin = 0; // select the input pin for the first pushbutton
int couterPin = 1; // select the pin for the second pushbutton
int potPin = 2; // select the pin for the potentiometer
int clocktransPin = 13; // select the pin for the counter clockwise rotation
int countertransPin = 12; // select the pin for the clockwise rotation
int speedPin = 11; // select the pin for the speed control
int clockwiseState = 0; // variable to store the value coming from the pushbutton
int counterState = 1; // variable to store the value coming from the pushbutton
int potValue = 0; //initial value stored in potentiometer
void setup() {
// declare each Pin as an INPUT:
pinMode(clockwisePin, INPUT);
pinMode(counterPin, INPUT);
pinMode(potPin, INPUT);
// declare each pin as an OUTPUT:
pinMode(clocktransPin, OUTPUT);
pinMode(countertransPin, OUTPUT);
pinMode(speedPin, OUTPUT);
}
void loop() {
// read the value from the potentiometer
potValue = analogRead(potPin);
// give output at pin 11
digitalWrite(speedPin, HIGH);
// stop the program for <potValue> milliseconds:
delay(1000);
// no output at pin 11
digitalWrite(speedPin, LOW);
// stop the program for for <potValue> milliseconds:
delay(1000);
}
void loop() {
// read the state of the pushbutton value:
clockwiseState = digitalRead(clockwisePin);
// check if the pushbutton is pressed. If it is, the clockwiseState is HIGH:
if (clockwiseState == HIGH) {
// give output at pin 12
digitalWrite(clockwisetransPin, HIGH);
} else {
// no output
digitalWrite(clockwisetransPin, LOW);
}
}
void loop() {
// read the state of the pushbutton value:
counterState = digitalRead(counterPin);
// check if the pushbutton is pressed. If it is, the clockwiseState is HIGH:
if (counterState == HIGH) {
// give output at pin 13
digitalWrite(countertransPin, HIGH);
} else {
// no output
digitalWrite(countertransPin, LOW);
}
}
Here are our arduino codes.
int clockwisePin = 0; // select the input pin for the first pushbutton
int couterPin = 1; // select the pin for the second pushbutton
int potPin = 2; // select the pin for the potentiometer
int clocktransPin = 13; // select the pin for the counter clockwise rotation
int countertransPin = 12; // select the pin for the clockwise rotation
int speedPin = 11; // select the pin for the speed control
int clockwiseState = 0; // variable to store the value coming from the pushbutton
int counterState = 1; // variable to store the value coming from the pushbutton
int potValue = 0; //initial value stored in potentiometer
void setup() {
// declare each Pin as an INPUT:
pinMode(clockwisePin, INPUT);
pinMode(counterPin, INPUT);
pinMode(potPin, INPUT);
// declare each pin as an OUTPUT:
pinMode(clocktransPin, OUTPUT);
pinMode(countertransPin, OUTPUT);
pinMode(speedPin, OUTPUT);
}
void loop() {
// read the value from the potentiometer
potValue = analogRead(potPin);
// give output at pin 11
digitalWrite(speedPin, HIGH);
// stop the program for <potValue> milliseconds:
delay(1000);
// no output at pin 11
digitalWrite(speedPin, LOW);
// stop the program for for <potValue> milliseconds:
delay(1000);
}
void loop() {
// read the state of the pushbutton value:
clockwiseState = digitalRead(clockwisePin);
// check if the pushbutton is pressed. If it is, the clockwiseState is HIGH:
if (clockwiseState == HIGH) {
// give output at pin 12
digitalWrite(clockwisetransPin, HIGH);
} else {
// no output
digitalWrite(clockwisetransPin, LOW);
}
}
void loop() {
// read the state of the pushbutton value:
counterState = digitalRead(counterPin);
// check if the pushbutton is pressed. If it is, the clockwiseState is HIGH:
if (counterState == HIGH) {
// give output at pin 13
digitalWrite(countertransPin, HIGH);
} else {
// no output
digitalWrite(countertransPin, LOW);
}
}
Part III. Breadboard
Click on the breadboard.
Arrange each component in the breadboard before connecting.
Now connect each component if you don’t know how to connect using breadboard just read my previous tutorial about how to construct a circuit in the breadboard
Application
The readers can create their own mechanism in controlling the speed and direction of rotation of a dc motor using arduino and FET transistor.
Like the example below.
Curriculum
Here are my other tutorials for electronic projects.
ELECTRONIC PROJECTS
Posted on Utopian.io - Rewarding Open Source Contributors
Thank you for the contribution. It has been approved.
You can contact us on Discord.
[utopian-moderator]
thanks @kizilelma
Hey @rfece143 I am @utopian-io. I have just upvoted you!
Achievements
Community-Driven Witness!
I am the first and only Steem Community-Driven Witness. Participate on Discord. Lets GROW TOGETHER!
Up-vote this comment to grow my power and help Open Source contributions like this one. Want to chat? Join me on Discord https://discord.gg/Pc8HG9x