Module 5: Power Management

Level: 🟢 Beginner
Board: Arduino Uno
Prerequisites: Modules 1–4
Estimated time: 50–60 minutes
Goal: Understand how to properly power any project and protect your components.


What You'll Learn

Sooner or later, every Arduino builder has the same experience: you add a servo or motor, and the board resets, LEDs flicker, or sensors give garbage readings. The circuit is correct. The code is correct. The power is wrong.

This module teaches you to think about power before you build: how to calculate what your circuit needs, choose the right source, and protect everything from the mistakes that will inevitably happen.


5.1 The Arduino's Power Budget

What the Uno Can Supply

Source Maximum Notes
Single digital pin 20 mA recommended, 40 mA absolute max Per pin. Exceeding this damages the ATmega328P
Total across all pins ~200 mA combined All GPIO pins together cannot exceed this
5V pin (from USB) ~500 mA Limited by USB port and polyfuse
5V pin (from barrel jack) ~800 mA Limited by onboard voltage regulator heat
3.3V pin 50 mA From the LP2985 regulator, very limited

Why This Matters

A single standard LED draws ~20 mA. That's fine. But here's what typical components actually draw:

Component Typical Current Draw
Standard LED 10–20 mA
RGB LED (all colors on) 60 mA
Micro servo (SG90, moving) 100–250 mA
Standard servo (moving under load) 500–1000 mA
Small DC motor 200–500 mA
HC-SR04 ultrasonic sensor 15 mA
DHT22 temperature sensor 1.5 mA
ESP8266 WiFi module (transmitting) 170–300 mA
OLED display (128×64) 10–20 mA
WS2812B LED strip (1 meter, full white) 1000–3000 mA

The key insight: A servo alone can pull more current than the Arduino's USB power supply allows. When it does, the voltage drops, the Arduino's voltage regulator loses regulation, and the board resets. This isn't a bug; it's a power budget failure.


5.2 Why Your Servo Resets the Board

This is the most common beginner power problem, so let's walk through exactly what happens:

  1. Your servo is powered from the Arduino's 5V pin
  2. The Arduino is powered via USB (~500 mA total)
  3. The servo needs 250 mA to move. The Arduino itself needs ~50 mA. Other components need another 30 mA. Total: 330 mA, which is fine when the servo is idle.
  4. But when the servo starts moving under load, it briefly pulls 500+ mA
  5. The USB power supply can't keep up. The 5V rail drops to 4V or lower.
  6. The ATmega328P's minimum operating voltage is 4.5V (at 16 MHz)
  7. The processor resets. Your sketch restarts from the beginning.
  8. The servo moves to its initial position, drawing a current spike again. The cycle repeats.

The Solution: Separate Power for Motors

Motors, servos, and other high-current components get their own power supply. The only connection to the Arduino is the signal wire (and a shared GND).

Arduino 5V pin → sensors, LEDs (low current)
Separate 5V supply → servos, motors (high current)
Both supplies share GND → required for signal reference

Critical rule: When using separate power supplies, the grounds MUST be connected together. Without a common ground, the Arduino's signal pins have no voltage reference for the servo's signal pin, and nothing works.


5.3 External Power Sources

Batteries

Type Voltage Capacity Best For
4×AA alkaline 6V (→ 5V via regulator) ~2500 mAh Portable Uno projects
9V block 9V ~500 mAh Short demos only, low capacity
18650 Li-ion 3.7V nominal 2000–3500 mAh Portable ESP projects
2×18650 7.4V (→ 5V via regulator) 2000–3500 mAh Portable high-power projects
LiPo pack (3.7V) 3.7V varies Compact/light builds
USB power bank 5V 5000–20000 mAh Easiest portable power

9V battery warning: A 9V battery might seem convenient, but it has very low capacity (~500 mAh) and high internal resistance. Under load, the voltage drops quickly. It's fine for testing but terrible for any project that runs more than an hour.

Wall Adapters

For stationary projects, a wall adapter is the most reliable choice:

USB Power

USB 2.0 provides 5V at up to 500 mA. USB 3.0 provides up to 900 mA. Neither is enough for motors or LED strips. USB-C power delivery can provide much more, but the Arduino Uno doesn't negotiate PD; it just takes 5V.


5.4 Voltage Regulators

A voltage regulator takes a higher input voltage and outputs a stable, lower voltage.

Linear Regulators (e.g., LM7805)

How they work: excess voltage is converted to heat.

Input: 9V, Output: 5V, Current: 500 mA
Power wasted as heat: (9V - 5V) × 0.5A = 2W

2W requires a heat sink. Without one, the regulator overheats and shuts down.

Pros: Simple, cheap, low noise, no external components needed Cons: Wastes energy as heat, dropout voltage (~2V minimum above output)

The Arduino Uno's onboard regulator is a linear type. That's why it accepts 7–12V and outputs 5V, and why feeding it 20V would be a problem (it would have to dissipate 15V × current as heat).

Switching Regulators (Buck Converters)

How they work: rapidly switch the input on and off, using an inductor and capacitor to smooth the output. Much more efficient.

Input: 9V, Output: 5V, Current: 500 mA
Efficiency: ~90%
Power wasted as heat: ~0.28W (vs. 2W for linear)

Pros: Very efficient (85–95%), minimal heat, works with larger voltage differences Cons: More complex circuit, can introduce electrical noise, more expensive

When to Use Which

Scenario Best Choice
Low current (<200 mA), small voltage drop Linear (simple, quiet)
High current (>500 mA) Switching (efficient, less heat)
Sensitive analog sensors Linear (less noise)
Battery-powered projects Switching (preserves battery life)
Quick prototype Linear (fewer components)

5.5 Logic Levels: 5V vs. 3.3V

The Arduino Uno operates at 5V logic. Many modern sensors and modules operate at 3.3V. Connecting them wrong can damage the 3.3V device.

The Problem

When a 5V Arduino pin outputs HIGH (5V) to a 3.3V sensor's input pin, the sensor receives 1.7V more than its rated maximum. Some sensors tolerate this (they have input protection). Many don't, and they'll fail silently or immediately.

Level Shifting Solutions

Voltage divider (5V → 3.3V only): Two resistors reduce 5V to 3.3V. Simple and free for one-directional signals.

5V signal → 1kΩ resistor → junction → 2kΩ resistor → GND
                              ↓
                     3.3V signal output

Calculation: 5V × (2kΩ / (1kΩ + 2kΩ)) = 3.33V ✓

Dedicated level shifter module (bidirectional): For I2C, SPI, or other protocols where data flows both ways, use a dedicated module like the TXB0108 or a MOSFET-based level shifter. These cost about $1 and handle 4–8 channels.

3.3V → 5V (reading 3.3V signals with a 5V Arduino): Good news: the ATmega328P considers anything above 3.0V as HIGH. So most 3.3V outputs can be read directly by a 5V Arduino without any level shifting.

Rule of thumb: 5V → 3.3V needs level shifting. 3.3V → 5V usually works directly. When in doubt, check the datasheet for the sensor's "HIGH" output voltage and the Arduino's "HIGH" input threshold.


5.6 Protection Components

Reverse Polarity Protection (Diode)

A diode in series with the positive supply line blocks current if you accidentally connect the battery backwards.

Battery + → Diode (band toward circuit) → Circuit +
Battery − → Circuit −

The diode drops about 0.7V, so factor this into your voltage budget. A Schottky diode (e.g., 1N5822) drops only ~0.3V and is preferred.

Fuse

A fuse breaks the circuit if too much current flows. Use a fuse rated slightly above your expected maximum current.

The Arduino Uno already has a resettable polyfuse (500 mA) on the USB line. For external power supplies, adding your own fuse is good practice.

Decoupling Capacitors

Every IC (including the ATmega328P, sensors, and display controllers) should have a 0.1µF ceramic capacitor placed as close as possible to its power pins. These absorb brief voltage spikes and dips caused by the IC switching internally.

IC VCC pin → 0.1µF capacitor → IC GND pin

The Arduino board already has decoupling capacitors for its own chips. But when you add external ICs or modules on a breadboard, adding a 0.1µF cap near each one prevents mysterious glitches.

For circuits with motors or servos, add a larger electrolytic capacitor (100µF–470µF) across the motor's power supply to absorb current spikes.


5.7 Reading Datasheets for Power Specs

From Module 6 onward, you'll source your own wiring from datasheets. Here's what to look for in the power sections:

Key Specifications

Spec What it tells you Example
Operating voltage (VCC) Required supply voltage range 3.3V–5.5V
Operating current How much current it draws during normal operation 15 mA
Peak current Maximum current during brief events (startup, transmission) 300 mA for 50ms
Standby/sleep current Current draw when idle 5 µA
Absolute maximum ratings Voltages that will destroy the component Max VCC: 7V
I/O voltage levels What voltage the pins output and expect as input 3.3V logic

Example: Reading the HC-SR04 Power Specs

From the HC-SR04 ultrasonic sensor datasheet:

This tells you: it needs 5V (not 3.3V), draws 15 mA when measuring, and 2 mA when idle. Well within a single Arduino pin's limit and a tiny fraction of the total power budget.


5.8 Calculating Total Power Budget

For any project, before you build, calculate the total current draw:

Step 1: List all components and their current draw

Component Current (mA) Source
Arduino Uno (itself) 50 Measured typical
LED × 3 60 (20 each) Datasheet
DHT22 sensor 2.5 Datasheet
OLED display 20 Datasheet
SG90 servo (moving) 250 Datasheet
Total 382.5 mA

Step 2: Add 20% safety margin

382.5 × 1.2 = 459 mA

Step 3: Choose a power source

USB provides 500 mA, just barely enough. But the servo's peak current could spike to 500 mA alone. Better solution: separate 5V/2A supply for the servo, USB for everything else.

Step 4: Verify voltage drops

If using a battery → linear regulator → circuit:

If using a diode for reverse polarity protection:


Module Project: Power Audit Lab

Objective

Take the night light from Module 4, add an external sensor (HC-SR04 ultrasonic) and a servo, calculate the total power budget, choose the right power supply, and add protection components.

Components Needed

Component Quantity Notes
Arduino Uno 1
USB-B cable 1
Breadboard 1 Full-size recommended
LED 1 From Module 4
220Ω Resistor 1 For LED
Pushbutton 1 From Module 4
Photoresistor + 10kΩ 1 each From Module 4
HC-SR04 Ultrasonic Sensor 1 New component
SG90 Micro Servo 1 New component
470µF Electrolytic Capacitor 1 For servo power smoothing
0.1µF Ceramic Capacitor 1 Decoupling for HC-SR04
External 5V/2A Power Supply 1 For servo power
Jumper wires 10+

Power Budget Calculation

Component Current (mA) Power Source
Arduino Uno 50 USB
LED (max brightness) 20 USB (via Arduino pin)
Photoresistor circuit 0.5 USB (via Arduino 5V)
HC-SR04 sensor 15 USB (via Arduino 5V)
SG90 servo (moving) 250 peak External 5V
Total from USB 85.5 mA Well within 500 mA ✓
Total from external 250 mA peak Well within 2A ✓

The Code

/*
 * Module 5 Project: Power Audit Lab
 *
 * Night light with ultrasonic proximity detection and servo arm.
 * When someone approaches (< 30cm), the servo waves and the LED activates.
 * Demonstrates proper power management with separate supplies.
 *
 * Circuit:
 * - LED + 220Ω → pin 9 (PWM)
 * - Button → pin 7 (INPUT_PULLUP)
 * - LDR + 10kΩ → A0
 * - HC-SR04: Trig → pin 10, Echo → pin 11
 * - Servo signal → pin 6, servo power from EXTERNAL 5V supply
 * - 470µF capacitor across external 5V supply
 * - 0.1µF capacitor near HC-SR04 VCC/GND
 * - External 5V GND connected to Arduino GND
 *
 * Board: Arduino Uno
 */

#include <Servo.h>

// --- Pin definitions ---
const int LED_PIN = 9;
const int BUTTON_PIN = 7;
const int SENSOR_PIN = A0;
const int TRIG_PIN = 10;
const int ECHO_PIN = 11;
const int SERVO_PIN = 6;

// --- State machine ---
enum LightState { STATE_OFF, STATE_DIM, STATE_BRIGHT, STATE_AUTO };
const char* STATE_NAMES[] = {"OFF", "DIM", "BRIGHT", "AUTO"};
LightState currentState = STATE_OFF;

// --- Servo ---
Servo myServo;
bool servoActive = false;
unsigned long servoStartTime = 0;
const unsigned long SERVO_WAVE_DURATION = 2000;

// --- Debounce ---
int lastButtonState = HIGH;
unsigned long lastDebounceTime = 0;
const unsigned long DEBOUNCE_DELAY = 50;

// --- Timing ---
unsigned long lastDistanceTime = 0;
const unsigned long DISTANCE_INTERVAL = 200;
unsigned long lastPrintTime = 0;
const unsigned long PRINT_INTERVAL = 500;

// --- Proximity ---
const int PROXIMITY_THRESHOLD_CM = 30;

void setup() {
  Serial.begin(9600);
  pinMode(LED_PIN, OUTPUT);
  pinMode(BUTTON_PIN, INPUT_PULLUP);
  pinMode(TRIG_PIN, OUTPUT);
  pinMode(ECHO_PIN, INPUT);

  myServo.attach(SERVO_PIN);
  myServo.write(90);  // Center position

  Serial.println("Power Audit Lab Ready");
  Serial.println("Night light + proximity servo");
  Serial.println("---");
  printPowerBudget();
}

void printPowerBudget() {
  Serial.println("=== POWER BUDGET ===");
  Serial.println("USB powered:");
  Serial.println("  Arduino:   ~50 mA");
  Serial.println("  LED:       ~20 mA max");
  Serial.println("  LDR circuit: ~0.5 mA");
  Serial.println("  HC-SR04:   ~15 mA");
  Serial.println("  USB total: ~85.5 mA (limit: 500 mA) OK");
  Serial.println("External 5V powered:");
  Serial.println("  Servo:     ~250 mA peak");
  Serial.println("  Ext total: ~250 mA (limit: 2000 mA) OK");
  Serial.println("====================");
}

long measureDistanceCM() {
  // Send trigger pulse
  digitalWrite(TRIG_PIN, LOW);
  delayMicroseconds(2);
  digitalWrite(TRIG_PIN, HIGH);
  delayMicroseconds(10);
  digitalWrite(TRIG_PIN, LOW);

  // Measure echo duration
  long duration = pulseIn(ECHO_PIN, HIGH, 30000);  // 30ms timeout

  if (duration == 0) {
    return -1;  // No echo — out of range or error
  }

  // Speed of sound: 343 m/s = 0.0343 cm/µs
  // Distance = (duration × 0.0343) / 2
  long distance = duration * 343 / 10000 / 2;
  return distance;
}

void handleButton() {
  unsigned long now = millis();
  int reading = digitalRead(BUTTON_PIN);

  if (reading != lastButtonState) {
    lastDebounceTime = now;
  }

  if ((now - lastDebounceTime) > DEBOUNCE_DELAY) {
    static int buttonState = HIGH;
    if (reading != buttonState) {
      buttonState = reading;
      if (buttonState == LOW) {
        switch (currentState) {
          case STATE_OFF:    currentState = STATE_DIM;    break;
          case STATE_DIM:    currentState = STATE_BRIGHT; break;
          case STATE_BRIGHT: currentState = STATE_AUTO;   break;
          case STATE_AUTO:   currentState = STATE_OFF;    break;
        }
        Serial.print("Mode: ");
        Serial.println(STATE_NAMES[currentState]);
      }
    }
  }
  lastButtonState = reading;
}

void handleLED() {
  switch (currentState) {
    case STATE_OFF:
      analogWrite(LED_PIN, 0);
      break;
    case STATE_DIM:
      analogWrite(LED_PIN, 50);
      break;
    case STATE_BRIGHT:
      analogWrite(LED_PIN, 255);
      break;
    case STATE_AUTO: {
      int light = analogRead(SENSOR_PIN);
      int brightness = map(light, 0, 1023, 255, 0);
      analogWrite(LED_PIN, constrain(brightness, 0, 255));
      break;
    }
  }
}

void handleServo() {
  unsigned long now = millis();

  if (servoActive) {
    // Wave the servo back and forth
    unsigned long elapsed = now - servoStartTime;
    if (elapsed < SERVO_WAVE_DURATION) {
      int angle = 90 + 45 * sin(elapsed / 200.0);
      myServo.write(angle);
    } else {
      myServo.write(90);  // Return to center
      servoActive = false;
    }
  }
}

void loop() {
  unsigned long now = millis();

  // Handle button
  handleButton();

  // Handle LED based on state
  handleLED();

  // Check distance periodically
  if (now - lastDistanceTime >= DISTANCE_INTERVAL) {
    lastDistanceTime = now;
    long distance = measureDistanceCM();

    if (distance > 0 && distance < PROXIMITY_THRESHOLD_CM && !servoActive) {
      servoActive = true;
      servoStartTime = now;
      Serial.print("Proximity detected: ");
      Serial.print(distance);
      Serial.println(" cm — servo activated");
    }
  }

  // Handle servo animation
  handleServo();

  // Periodic status print
  if (now - lastPrintTime >= PRINT_INTERVAL) {
    lastPrintTime = now;
    long dist = measureDistanceCM();
    Serial.print("Mode: ");
    Serial.print(STATE_NAMES[currentState]);
    Serial.print("  Distance: ");
    if (dist > 0) {
      Serial.print(dist);
      Serial.print("cm");
    } else {
      Serial.print("---");
    }
    Serial.print("  Servo: ");
    Serial.println(servoActive ? "ACTIVE" : "idle");
  }
}

Circuit Diagram

<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 900 520" font-family="monospace" font-size="11">
  <!-- Arduino -->
  <rect x="30" y="120" width="140" height="300" fill="#1a7a8a" stroke="#333" stroke-width="2" rx="8"/>
  <text x="100" y="150" text-anchor="middle" fill="white" font-size="14" font-weight="bold">Arduino</text>
  <text x="100" y="168" text-anchor="middle" fill="white" font-size="12">Uno</text>

  <!-- USB label -->
  <rect x="65" y="110" width="70" height="18" fill="#888" stroke="#333" stroke-width="1.5" rx="3"/>
  <text x="100" y="123" text-anchor="middle" font-size="9" fill="white">USB (500mA)</text>

  <!-- Arduino pins -->
  <rect x="170" y="175" width="22" height="14" fill="#2a8a9a" stroke="white" stroke-width="1" rx="2"/>
  <text x="181" y="185" text-anchor="middle" fill="white" font-size="8">5V</text>
  <rect x="170" y="195" width="22" height="14" fill="#2a8a9a" stroke="white" stroke-width="1" rx="2"/>
  <text x="181" y="205" text-anchor="middle" fill="white" font-size="8">GND</text>
  <rect x="170" y="225" width="22" height="14" fill="#2a8a9a" stroke="white" stroke-width="1" rx="2"/>
  <text x="181" y="235" text-anchor="middle" fill="white" font-size="8">A0</text>
  <rect x="170" y="255" width="22" height="14" fill="#2a8a9a" stroke="white" stroke-width="1" rx="2"/>
  <text x="181" y="265" text-anchor="middle" fill="white" font-size="8">D6</text>
  <rect x="170" y="285" width="22" height="14" fill="#2a8a9a" stroke="white" stroke-width="1" rx="2"/>
  <text x="181" y="295" text-anchor="middle" fill="white" font-size="8">D7</text>
  <rect x="170" y="315" width="22" height="14" fill="#2a8a9a" stroke="white" stroke-width="1" rx="2"/>
  <text x="181" y="325" text-anchor="middle" fill="white" font-size="8">D9</text>
  <rect x="170" y="345" width="22" height="14" fill="#2a8a9a" stroke="white" stroke-width="1" rx="2"/>
  <text x="181" y="355" text-anchor="middle" fill="white" font-size="8">D10</text>
  <rect x="170" y="375" width="22" height="14" fill="#2a8a9a" stroke="white" stroke-width="1" rx="2"/>
  <text x="181" y="385" text-anchor="middle" fill="white" font-size="8">D11</text>

  <!-- === EXTERNAL POWER SUPPLY === -->
  <rect x="620" y="120" width="120" height="60" fill="#cc4444" stroke="#333" stroke-width="2" rx="6"/>
  <text x="680" y="145" text-anchor="middle" fill="white" font-size="11" font-weight="bold">External</text>
  <text x="680" y="162" text-anchor="middle" fill="white" font-size="10">5V / 2A</text>

  <!-- Capacitor across external supply -->
  <rect x="760" y="140" width="35" height="20" fill="none" stroke="#333" stroke-width="1.5" rx="3"/>
  <text x="778" y="154" text-anchor="middle" font-size="8">470µF</text>

  <!-- External 5V rail -->
  <line x1="680" y1="180" x2="680" y2="260" stroke="red" stroke-width="2.5"/>
  <text x="680" y="215" text-anchor="middle" font-size="10" fill="red" font-weight="bold">EXT 5V</text>

  <!-- External GND -->
  <line x1="720" y1="180" x2="720" y2="460" stroke="blue" stroke-width="2.5"/>

  <!-- GND connection between external and Arduino -->
  <line x1="192" y1="202" x2="720" y2="202" stroke="blue" stroke-width="2" stroke-dasharray="6,3"/>
  <text x="450" y="196" text-anchor="middle" font-size="9" fill="blue" font-weight="bold">SHARED GND (critical!)</text>

  <!-- === SERVO (powered externally) === -->
  <rect x="560" y="260" width="80" height="50" fill="#ff9933" stroke="#333" stroke-width="2" rx="4"/>
  <text x="600" y="282" text-anchor="middle" font-size="10" font-weight="bold">Servo</text>
  <text x="600" y="298" text-anchor="middle" font-size="9">SG90</text>

  <!-- Servo power from external -->
  <line x1="640" y1="270" x2="680" y2="270" stroke="red" stroke-width="2"/>
  <text x="660" y="265" text-anchor="middle" font-size="8" fill="red">5V</text>
  <line x1="640" y1="300" x2="720" y2="300" stroke="blue" stroke-width="2"/>

  <!-- Servo signal from Arduino D6 -->
  <line x1="192" y1="262" x2="560" y2="262" stroke="orange" stroke-width="2"/>
  <text x="380" y="255" text-anchor="middle" font-size="9" fill="orange">Signal (D6)</text>

  <!-- === HC-SR04 (powered from Arduino) === -->
  <rect x="350" y="350" width="90" height="45" fill="#6699cc" stroke="#333" stroke-width="2" rx="4"/>
  <text x="395" y="370" text-anchor="middle" font-size="10" font-weight="bold" fill="white">HC-SR04</text>
  <text x="395" y="386" text-anchor="middle" font-size="9" fill="white">15 mA</text>

  <!-- 0.1uF cap near HC-SR04 -->
  <rect x="450" y="358" width="32" height="14" fill="none" stroke="#333" stroke-width="1" rx="2"/>
  <text x="466" y="368" text-anchor="middle" font-size="7">0.1µF</text>

  <!-- HC-SR04 connections -->
  <line x1="350" y1="360" x2="260" y2="360" stroke="red" stroke-width="1.5"/>
  <line x1="260" y1="360" x2="260" y2="182" stroke="red" stroke-width="1.5"/>
  <line x1="260" y1="182" x2="192" y2="182" stroke="red" stroke-width="1.5"/>
  <text x="290" y="370" text-anchor="middle" font-size="8" fill="red">VCC</text>

  <line x1="192" y1="352" x2="350" y2="370" stroke="green" stroke-width="1.5"/>
  <text x="270" y="348" text-anchor="middle" font-size="8" fill="green">Trig (D10)</text>

  <line x1="192" y1="382" x2="350" y2="382" stroke="purple" stroke-width="1.5"/>
  <text x="270" y="395" text-anchor="middle" font-size="8" fill="purple">Echo (D11)</text>

  <!-- LED + Button + LDR label -->
  <rect x="250" y="430" width="220" height="40" fill="#f0f0f0" stroke="#999" stroke-width="1" rx="4"/>
  <text x="360" y="448" text-anchor="middle" font-size="10">LED (D9) + Button (D7) + LDR (A0)</text>
  <text x="360" y="462" text-anchor="middle" font-size="9" fill="#666">Same as Module 4 wiring</text>

  <!-- Legend -->
  <rect x="30" y="460" width="200" height="50" fill="#f8f8f8" stroke="#ccc" stroke-width="1" rx="4"/>
  <text x="40" y="478" font-size="9" fill="red">■ Red = power (5V)</text>
  <text x="40" y="492" font-size="9" fill="blue">■ Blue = GND</text>
  <text x="40" y="506" font-size="9" fill="orange">■ Orange/Green/Purple = signals</text>
</svg>

Circuit Schema (JSON)

{
  "module": 5,
  "project": "Power Audit Lab",
  "board": "Arduino Uno",
  "schematic": {
    "components": [
      {
        "id": "U1",
        "type": "arduino_uno",
        "pins_used": {
          "5V": "net_arduino_vcc",
          "GND": "net_gnd",
          "A0": "net_sensor_junction",
          "D6": "net_servo_signal",
          "D7": "net_button",
          "D9": "net_led_drive",
          "D10": "net_trig",
          "D11": "net_echo"
        }
      },
      {
        "id": "PS1",
        "type": "power_supply",
        "value": "5V",
        "max_current": "2A",
        "description": "External 5V power supply for servo",
        "pins": { "positive": "net_ext_vcc", "negative": "net_gnd" }
      },
      {
        "id": "C1",
        "type": "capacitor_electrolytic",
        "value": "470",
        "unit": "uF",
        "voltage_rating": "16V",
        "purpose": "Servo power smoothing",
        "pins": { "positive": "net_ext_vcc", "negative": "net_gnd" }
      },
      {
        "id": "SERVO1",
        "type": "servo",
        "model": "SG90",
        "current_draw": { "idle": "10mA", "moving": "100-250mA" },
        "pins": {
          "signal": "net_servo_signal",
          "vcc": "net_ext_vcc",
          "gnd": "net_gnd"
        }
      },
      {
        "id": "US1",
        "type": "ultrasonic_sensor",
        "model": "HC-SR04",
        "current_draw": "15mA",
        "pins": {
          "vcc": "net_arduino_vcc",
          "trig": "net_trig",
          "echo": "net_echo",
          "gnd": "net_gnd"
        }
      },
      {
        "id": "C2",
        "type": "capacitor_ceramic",
        "value": "100",
        "unit": "nF",
        "purpose": "Decoupling for HC-SR04",
        "pins": { "pin1": "net_arduino_vcc", "pin2": "net_gnd" },
        "placement": "As close to HC-SR04 VCC/GND as possible"
      },
      {
        "id": "LDR1", "type": "photoresistor",
        "pins": { "pin1": "net_arduino_vcc", "pin2": "net_sensor_junction" }
      },
      {
        "id": "R1", "type": "resistor", "value": "10000", "unit": "ohm",
        "pins": { "pin1": "net_sensor_junction", "pin2": "net_gnd" }
      },
      {
        "id": "R2", "type": "resistor", "value": "220", "unit": "ohm",
        "pins": { "pin1": "net_led_drive", "pin2": "net_r2_led" }
      },
      {
        "id": "LED1", "type": "led", "color": "white",
        "pins": { "anode": "net_r2_led", "cathode": "net_gnd" }
      },
      {
        "id": "SW1", "type": "pushbutton",
        "pins": { "pinA": "net_button", "pinB": "net_gnd" }
      }
    ],
    "nets": [
      { "name": "net_gnd", "description": "SHARED ground (Arduino + external supply)", "nodes": ["U1.GND", "PS1.negative", "C1.negative", "SERVO1.gnd", "US1.gnd", "C2.pin2", "R1.pin2", "LED1.cathode", "SW1.pinB"] },
      { "name": "net_arduino_vcc", "description": "Arduino 5V (USB powered, low-current devices)", "nodes": ["U1.5V", "LDR1.pin1", "US1.vcc", "C2.pin1"] },
      { "name": "net_ext_vcc", "description": "External 5V (high-current devices)", "nodes": ["PS1.positive", "C1.positive", "SERVO1.vcc"] },
      { "name": "net_servo_signal", "nodes": ["U1.D6", "SERVO1.signal"] },
      { "name": "net_trig", "nodes": ["U1.D10", "US1.trig"] },
      { "name": "net_echo", "nodes": ["U1.D11", "US1.echo"] },
      { "name": "net_sensor_junction", "nodes": ["LDR1.pin2", "R1.pin1", "U1.A0"] },
      { "name": "net_led_drive", "nodes": ["U1.D9", "R2.pin1"] },
      { "name": "net_r2_led", "nodes": ["R2.pin2", "LED1.anode"] },
      { "name": "net_button", "nodes": ["U1.D7", "SW1.pinA"] }
    ],
    "power": {
      "usb_source": { "voltage": 5.0, "max_current_ma": 500, "used_ma": 85.5 },
      "external_source": { "voltage": 5.0, "max_current_ma": 2000, "used_ma": 250 },
      "note": "Grounds MUST be connected between USB and external supply"
    }
  },
  "code": { "filename": "module05_power_audit.ino", "language": "cpp" },
  "validation": {
    "expected_behavior": "Night light modes work as Module 4. Ultrasonic detects proximity, servo waves. No board resets under servo load.",
    "power_checks": [
      "Verify servo doesn't cause Arduino reset (no flickering LEDs during servo movement)",
      "Measure voltage on Arduino 5V pin during servo activation — should stay above 4.8V",
      "Measure current from external supply during servo movement — should be under 300mA"
    ],
    "common_mistakes": [
      "Board resets when servo moves: servo is drawing power from Arduino, not external supply",
      "Servo doesn't move: signal wire not connected, or servo powered but no shared GND",
      "HC-SR04 returns -1 always: check VCC and GND connections, add 0.1µF decoupling cap",
      "Erratic sensor readings: missing decoupling capacitor near HC-SR04"
    ]
  }
}

Self-Check: Module 5

Before moving to Module 6, make sure you can:


Key Terms Glossary

Term Definition
Power budget The total current draw of all components vs. what the supply can provide
Current draw How much current a component consumes during operation
Voltage regulator A component that maintains a stable output voltage from a varying input
Linear regulator Converts excess voltage to heat. Simple but wasteful
Switching regulator Uses rapid switching for efficient voltage conversion
Dropout voltage The minimum difference between input and output a linear regulator needs
Decoupling capacitor A small capacitor placed near an IC to absorb voltage fluctuations
Reverse polarity protection A diode that blocks current if the power supply is connected backwards
Logic level The voltage that represents HIGH (5V for Uno, 3.3V for many modern chips)
Level shifter A circuit that converts signals between different logic voltages
Shared ground Connecting grounds between separate power supplies, essential for signals to work
Back-EMF Voltage spike generated when a motor is suddenly stopped
Flyback diode Protects circuits from back-EMF by providing a safe current path
Polyfuse A self-resetting fuse. The Arduino Uno has one on the USB line

Previous: ← Module 4: Logic & Control Flow Next: Module 6: Sensors Deep Dive: Reading the Environment →