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:

  1. Understand how to drive a DC motor safely using a transistor as a switch.

  2. Explain the role of a diode in protecting the circuit from back EMF.

  3. Write and upload Arduino code to control the motor.

  4. 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)

  1. Motor Connections

    • Motor terminal 1 → Arduino 5V pin

    • Motor terminal 2 → Collector of transistor (2N2222)

  2. Transistor Connections (2N2222)

    • Emitter → Arduino GND

    • Base → Arduino Digital Pin 9 via 220Ω resistor

  3. 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)

  4. 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

  1. Motor not rotating → Check if transistor legs (E, B, C) are wired correctly.

  2. Arduino resets when motor runs → Missing diode across motor terminals.

  3. Motor always ON → Base resistor not connected, causing leakage current.

  4. No response in Tinkercad → Check that code is uploaded and simulation is running.


Viva / Check-Your-Understanding

  1. Why can’t we connect the motor directly to Arduino pin?

  2. What is the role of the transistor in this circuit?

  3. Why is a diode placed across the motor terminals?

  4. Can we use PWM to control motor speed? If yes, how?


Extensions (Mini-Tasks)

  1. Modify the code to make the motor run for 1 second ON, 2 seconds OFF.

  2. Use analogWrite() instead of digitalWrite() to control motor speed.

  3. 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

Comments

Popular posts from this blog