All programs
IoT - Lab Manual (Simplified) · BCS7O3 IoT (Arduino · C++)

Problem Statement Program 4

Develop a program to control a DC Motor with Arduino Board.

To interface and control a DC motor using an Arduino Uno board and a transistor driver circuit. This experiment helps in understanding motor control, transistor switching, flyback diode protection, and Arduino digital output.

Components Required Hardware

Arduino Uno Board – 1
DC Motor (3V–6V) – 1
TIP120 Transistor / BC547 Transistor – 1
1N4007 Diode (Flyback Protection) – 1
220Ω Resistor – 1
Breadboard – 1
Jumper Wires – As Required
USB Cable – 1
External Power Supply (Optional)

Procedure Step by step

Step 1:

Take an Arduino Uno board, DC motor, transistor (TIP120/BC547), diode, resistor, breadboard, jumper wires, and USB cable.

Step 2:

Place the transistor on the breadboard.

Step 3:

Connect the collector pin of the transistor to one terminal of the DC motor.

Step 4:

Connect the other terminal of the DC motor to the 5V supply (or external power supply).

Step 5:

Connect the emitter pin of the transistor to the Arduino GND.

Step 6:

Connect a 1N4007 diode across the motor terminals.

Cathode → +5V side
Anode → Collector side
Step 7:

Connect the base of the transistor to Arduino Digital Pin 9 through a 220Ω resistor.

Step 8:

Connect the Arduino Uno to the computer using a USB cable.

Step 9:

Open the Arduino IDE.

Step 10:

Select Tools → Board → Arduino Uno.

Step 11:

Select the correct COM Port.

Step 12:

Copy and paste the Arduino program.

Step 13:

Compile and upload the program.

Step 14:

Observe the DC motor rotating for one second and stopping for one second continuously.

Circuit Connection Wiring

Arduino Digital Pin 9 → 220Ω Resistor → Transistor Base
Transistor Collector → One Terminal of DC Motor
Other Terminal of DC Motor → Arduino 5V (or External Power Supply)
Transistor Emitter → Arduino GND
1N4007 Diode Cathode → Motor +5V Terminal
1N4007 Diode Anode → Motor Collector Terminal
Arduino USB → Computer

Circuit Diagram 1 image

Download the clean, watermark-free circuit diagram — ₹1.00

Arduino Code (C++) Source

program4.cpp
// DC Motor Control Pin
int pin = 9;

void setup()
{
  pinMode(pin, OUTPUT);
}

void loop()
{
  // Motor ON
  digitalWrite(pin, HIGH);
  delay(1000);

  // Motor OFF
  digitalWrite(pin, LOW);
  delay(1000);
}
Protected content · © VTU Developer · Unauthorised distribution is prohibited