DC Motor Interfacing With Arduino Board

DC Motor Interfacing With Arduino Board

Various types of motors can be controlled with Arduino (like stepper, servo motor, DC motor etc). But in this article, we will only control the dc motor. This dc motor is only 6v so the transistor is enough to control it but 9v, 12v require some extra board (like L298N) which provides a power supply to the dc motor.

Components Required:

  1. 1x PN2222 Transistor
  2. 1x Small 6V DC Motor
  3. 1x 1N4001 diode
  4. 1x 270 Ω Resistor
  5. 1x Arduino UNO board

 

Circuit Diagram:

dc-motor-board-interfacing-with-arduino

 

Steps To Follow:

  1. Open Arduino IDE.
  2. Click on File.
  3. Go to New. – A new File will open
  4. Remove the Pre-Written code.
  5. Paste the code given below:
  6. Check whether your UNO has been detected by the ID by going to Tools.
  7. Click on Port – Select the COM-Port on which Arduino UNO is detected. 

Code:

int motorPin = 3;
void setup() {
}
void loop() {
digitalWrite(motorPin, HIGH);
}

 

Challenges:

(a) Run the motor for 5 seconds and stop for 2 seconds and run again for 5 seconds

(b) Run the motor in reverse direction

(c) Run the motor first in a forward direction for 5 seconds and then in a reverse direction for the next 5 seconds

Leave a comment