Guided physical computing, beginning with the Arduino Starter Kit Classroom Pack

Arduino Uno R3

Switch a DC motor safely

Use the kit IRF520 MOSFET and 1N4007 flyback diode to switch a DC motor without driving it directly from an Arduino pin.

CSTA 2026 mapping candidatesNot reviewed by CSTA
MS-SYS-HW-30Systems & SecurityMS-PRO-TR-19Programming

Students will

  • Explain why a GPIO pin must not power a motor
  • Use a transistor as a controlled switch
  • Place a flyback diode across the motor with correct polarity

Evidence of success

  • The motor is never connected directly to a GPIO pin
  • The diode and transistor identities and orientations are documented
  • The motor starts and stops repeatedly without resetting the Uno or overheating components

Hardware

  • Arduino Uno R3
  • Starter Kit DC motor
  • IRF520 MOSFET
  • 1N4007 diode
  • Reviewed resistor and 100 µF capacitor
  • Teacher-approved motor supply
  • Breadboard and jumper wires

Prerequisites

  • Build a digital output
  • Distinguish signal power from motor power
  • Identify the exact transistor pins

Before class

  • Verify the IRF520 gate, drain, and source pinout against the exact part
  • Verify motor running and stall-current requirements
  • Approve the supply and prepare an immediate disconnect method

Reviewed connection map

Transistor-switched motor load

D9Low-current control signal
Driver + flyback diodeSwitches motor current and limits inductive voltage
DC motorNever connected directly to GPIO
Reviewed motor supplyPower sized for the load; common ground where required
  1. Build the reviewed transistor, resistor, diode, and motor circuit with all power disconnected.
  2. Connect D9 only to the driver control path, not directly to the motor.
  3. Verify diode orientation, supply polarity, and a common reference before testing.

Build and test

  1. 01Record the IRF520 pinout, motor limits, and approved supply
  2. 02Build the gate-control and motor-current paths with power disconnected
  3. 03Place the 1N4007 across the motor in the reviewed flyback orientation and place the capacitor only as specified by the reviewed circuit
  4. 04Establish common ground between the Uno and motor supply where the circuit requires it
  5. 05Upload an on-off test and check the motor, MOSFET, and wiring for heat

Read before uploading

Annotated Arduino sketch

const int MOTOR_CONTROL_PIN = 9;

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

void loop() {
  digitalWrite(MOTOR_CONTROL_PIN, HIGH);
  delay(1000);
  digitalWrite(MOTOR_CONTROL_PIN, LOW);
  delay(1000);
}

Optional engineering record

Record evidence from this lesson

Choose the prompts that help students explain predictions, evidence, debugging, and transfer. Saving creates a new entry in this browser’s Rudi notebook.

Record your thinking — optional4 prompts

Use these prompts if they help students capture evidence, decisions, or questions. You do not need to complete every prompt or create an entry at every step.

Nothing is saved until you choose this button.

Troubleshooting

The Uno resets when the motor starts

Stop testing and review supply capacity, common ground, wiring, motor noise suppression, and mechanical load.

The motor stays off

Disconnect power and verify transistor pinout, diode orientation, control resistor, common ground, and motor supply.

2026 middle school standards

Potential CSTA connections

Not reviewed by CSTA

These are evidence-based crosswalk candidates for curriculum review—not a claim of official alignment.

MS-SYS-HW-30

Examine differences between computing systems based on user needs, system requirements, and potential societal, environmental, and ethical impacts.

Students distinguish the controller, switching device, motor supply, and shared reference as parts of one system.

Lesson evidence: Labeled control and power path
MS-PRO-TR-19

Use systematic strategies to test, refine, and document changes to a computing technology to meet the intended purpose.

Students isolate variables, compare observed behavior with the intended purpose, and document a revision.

Lesson evidence: Motor switching test log
View the official 2026 CSTA standardsStandard text: Computer Science Teachers Association (2026), CC BY-NC-SA 4.0.

Supporting concepts

motor-types · motor-control · power-and-signals

Sources and review

Arduino Uno R3 documentationArduino Projects Book · CC BY-NC-SA 3.0Vishay IRF520 datasheet

Starting point, not verified curriculum. Review the actual hardware, circuit, code, power requirements, and classroom conditions.

After teaching this lesson

Make one bounded change—or connect the skill to a project.