Lab set Program-4
Develop a program to control a DC motor with Arduino board.
Objective
To interface a DC motor with Arduino Uno in Tinkercad and control its ON/OFF operation using a transistor as a driver and a diode for back EMF protection.
Learning Outcomes
By the end of this lab, students will be able to:
-
Understand how to drive a DC motor safely using a transistor as a switch.
-
Explain the role of a diode in protecting the circuit from back EMF.
-
Write and upload Arduino code to control the motor.
-
Build and test a motor control circuit in Tinkercad.
Components (from Tinkercad Palette)
-
Arduino Uno R3
-
DC Motor
-
Breadboard (small)
-
NPN Transistor (2N2222)
-
Diode (1N4007)
-
Resistor (220Ω)
-
Jumper wires
Circuit Wiring (Exact)
-
Motor Connections
-
Motor terminal 1 → Arduino 5V pin
-
Motor terminal 2 → Collector of transistor (2N2222)
-
-
Transistor Connections (2N2222)
-
Emitter → Arduino GND
-
Base → Arduino Digital Pin 9 via 220Ω resistor
-
-
Diode Placement (for protection)
-
Place diode across motor terminals
-
Cathode (line side) → connected to Motor terminal at 5V
-
Anode → connected to Motor terminal at Collector (transistor side)
-
-
Power and Ground
-
Arduino 5V → Breadboard positive rail
-
Arduino GND → Breadboard negative rail
Arduino Sketch
// Lab Program 4: DC Motor Control in Tinkercad
int motorPin = 9; // Motor control via transistor base
void setup() {
pinMode(motorPin, OUTPUT);
}
void loop() {
digitalWrite(motorPin, HIGH); // Motor ON
delay(3000); // 3 seconds ON
digitalWrite(motorPin, LOW); // Motor OFF
delay(3000); // 3 seconds OFF
}
How it Works
-
Arduino sends a HIGH signal on Pin 9 → current flows into transistor base → transistor switches ON → motor runs.
-
Arduino sends LOW → transistor OFF → motor stops.
-
The diode blocks reverse current caused by motor coil’s back EMF → protects Arduino and transistor.
Common Mistakes & Quick Fixes
-
Motor not rotating → Check if transistor legs (E, B, C) are wired correctly.
-
Arduino resets when motor runs → Missing diode across motor terminals.
-
Motor always ON → Base resistor not connected, causing leakage current.
-
No response in Tinkercad → Check that code is uploaded and simulation is running.
Viva / Check-Your-Understanding
-
Why can’t we connect the motor directly to Arduino pin?
-
What is the role of the transistor in this circuit?
-
Why is a diode placed across the motor terminals?
-
Can we use PWM to control motor speed? If yes, how?
Extensions (Mini-Tasks)
-
Modify the code to make the motor run for 1 second ON, 2 seconds OFF.
-
Use
analogWrite()instead ofdigitalWrite()to control motor speed. -
Replace motor ON/OFF with a button press input from Arduino.
Lab Record (Suggested Headings)
-
Title
-
Objective
-
Components Used
-
Circuit Diagram (Tinkercad screenshot)
-
Arduino Code
-
Output
Thinkercad Link:
https://www.tinkercad.com/things/bKjuTssXFdV-labset-prog-4
.png)
Comments
Post a Comment