Design and validate Closed-Loop DC Motor Speed Controller. The completed prototype must start safely, produce repeatable measurements, report faults and include recorded evidence.
System design
Circuit & Wiring Studio
Exact target required
Drag components. In Connect mode, select one pin and then another pin.
const int PWM_PIN=5,DIR_PIN=4;
void setup(){pinMode(PWM_PIN,OUTPUT);pinMode(DIR_PIN,OUTPUT);Serial.begin(115200);}
void loop(){digitalWrite(DIR_PIN,HIGH);for(int duty=0;duty<=255;duty+=15){analogWrite(PWM_PIN,duty);Serial.println(duty);delay(150);}analogWrite(PWM_PIN,0);delay(1000);}
Testing and observations
Install the exact board support package and select the correct target.
Create a new project and add only the documented dependencies.
Compile before connecting external hardware.
Wire with power disconnected and verify continuity/polarity.
Upload through a known data cable and open Serial Monitor at the configured baud rate.
Run subsystem tests, then integrate one module at a time.
Test
Expected
Instrument
Acceptance criteria
Controller supply
Nominal board rail
±5%
DMM
GPIO LOW
Near 0 V
<0.2 V typical
DMM/scope
GPIO HIGH
Logic rail
Within datasheet VOH
DMM/scope
Load-event rail
No brownout dip
Board specific
Oscilloscope
Viva questions
Why is supply margin required?
Loads and radios can draw transient current above their average.
Why must voltage limits be checked?
Excess pin voltage can cause injection current, malfunction or permanent damage.
Why test subsystems separately?
It isolates faults and produces traceable evidence.
Prototype safety
Verify voltage, polarity, GPIO limits and isolation before power-up. Use current limiting and disconnect power before wiring changes.
Guided practical
Complete learning and build guide
Advanced6–10 hoursMotors, relays and robotics
Objective
Design and validate Closed-Loop DC Motor Speed Controller. The completed prototype must start safely, produce repeatable measurements, report faults and include recorded evidence.
Required knowledge
GPIO and electrical limits
Reading a schematic and pin table
Compiler, upload and Serial Monitor use
Multimeter safety and measurement uncertainty
Power and current calculation
Calculate total current before wiring: controller + sensors + display/communications + actuator peak current. Add at least 25% supply margin. Never power a motor, relay coil or high-current load directly from GPIO. Measure the regulated rail during the highest-load event.
Libraries and build procedure
Libraries: Board support package for Arduino, Only libraries explicitly required by the selected sensor/module, Use pinned, documented library versions
Install the exact board support package and select the correct target.
Create a new project and add only the documented dependencies.
Compile before connecting external hardware.
Wire with power disconnected and verify continuity/polarity.
Upload through a known data cable and open Serial Monitor at the configured baud rate.
Run subsystem tests, then integrate one module at a time.
Complete source code
const int PWM_PIN=5,DIR_PIN=4;
void setup(){pinMode(PWM_PIN,OUTPUT);pinMode(DIR_PIN,OUTPUT);Serial.begin(115200);}
void loop(){digitalWrite(DIR_PIN,HIGH);for(int duty=0;duty<=255;duty+=15){analogWrite(PWM_PIN,duty);Serial.println(duty);delay(150);}analogWrite(PWM_PIN,0);delay(1000);}
Section
Explanation
Pin definitions
Centralise hardware mapping so board changes are controlled.
setup()
Configure safe initial outputs, communications and peripherals.
loop()/tasks
Sample inputs, update state and report results without unsafe output transitions.
Fault handling
Detect invalid readings/timeouts and force a defined safe state.
Improve regulator/decoupling and remove load from GPIO
Communication timeout
Logic voltage, address/baud and pull-ups
Level-shift and correct protocol settings
Extension challenges
Replace blocking delays with a state machine.
Add timestamped fault history and recovery counters.
Measure actual power consumption and calculate battery life.
Add configuration validation and factory reset.
Create a production self-test mode.
Project-report guidance
Include the problem statement, block diagram, schematic, BOM, pin table, power budget, firmware version, test instruments, expected versus measured results, fault log, photographs, conclusion and proposed improvements.