Skip to content
BoKSA

Prototyping & electronics

Basics of Electronics

Introduction

Embedded systems sit at the boundary between software and the physical world. Your microcontroller thinks in logic levels and code, but sensors, LEDs, motors, and power supplies obey the laws of electricity. Understanding a handful of core components and relationships — voltage, current, resistance, and how common parts behave in a circuit — helps you wire prototypes safely, choose the right values, and debug problems that look like "software bugs" but are actually hardware issues.

This article covers the fundamentals you need before (or alongside) your first breadboard projects: Ohm's law, resistor color codes, and the behavior of LEDs, diodes, capacitors, inductors, and field-effect transistors (FETs). The goal is practical literacy, not becoming an electrical engineer overnight.


Voltage, current, and resistance

Three quantities appear in almost every embedded circuit:

Quantity Symbol Unit What it means
Voltage V (or U) volt (V) Electrical "pressure" — the potential difference between two points
Current I ampere (A) Flow of charge through a conductor
Resistance R ohm (Ω) Opposition to current flow

Current is often measured in milliamperes (mA) in low-power circuits. A typical indicator LED runs at roughly 5–20 mA; an ESP32 GPIO pin can only source a limited amount of current.


Ohm's law

Ohm's law describes the relationship between voltage, current, and resistance in ohmic conductors (most metals and fixed resistors):

1
V = I × R

You can rearrange this as needed:

  • I = V / R
  • R = V / I

Example: A 220 Ω resistor connected to 3.3 V draws:

1
I = 3.3 V / 220 Ω ≈ 15 mA

Not every component is ohmic. Diodes, LEDs, and transistors have a non-linear relationship between voltage and current — their effective resistance changes with the applied voltage. Temperature also affects resistance: in most metals, resistance rises as the material heats up.

A useful mental model is the hydraulic analogy: voltage is like water pressure, current is flow rate, and resistance is a narrow pipe.


Resistor color codes

Before surface-mount parts dominated consumer electronics, resistors were marked with colored bands so their value could be read from any angle — even when the printed side was hidden on a PCB. The system is standardized in IEC 60757.

Color values

Color Digit Multiplier Tolerance
Black 0 ×1
Brown 1 ×10 ±1%
Red 2 ×100 ±2%
Orange 3 ×1 000
Yellow 4 ×10 000
Green 5 ×100 000
Blue 6 ×1 000 000 ±0.25%
Violet 7 ×10 000 000 ±0.1%
Grey 8 ±0.05%
White 9
Gold ×0.1 ±5%
Silver ×0.01 ±10%

A common mnemonic for the digit order is: "Bad Booze Rots Our Young Guts But Vodka Goes Well – get some now." (Black, Brown, Red, Orange, Yellow, Green, Blue, Violet, Grey, White). The rainbow order (red through violet) matches the digit sequence, which some people find easier to remember.

How to read the bands

  1. Find the correct end. The tolerance band (gold or silver) is usually at the far end and may be slightly wider or spaced farther from the other bands. The first band is never gold or silver.
  2. First and second bands give the first two digits.
  3. Third band is the multiplier (how many zeros to append). Four-band resistors use the third band as the multiplier; five-band resistors use the third band as the third digit.
  4. Fourth band (if present) is tolerance. Three-band resistors without a tolerance band are ±20% — a type rarely made today.

Examples

Bands Value
Yellow – Violet – Red – Gold 47 × 10² = 4,700 Ω (4.7 kΩ), ±5%
Red – Red – Orange – Gold 22 × 10³ = 22,000 Ω (22 kΩ), ±5%
Green – Blue – Black – Black – Brown 560 Ω, ±1%

Resistors are manufactured in standard E-series values (E12 is the most common for general use). You rarely find every possible number — pick the nearest standard value (e.g. 170 Ω → 180 Ω from the E12 series).

Color vision

Color vision varies — some people have difficulty distinguishing certain resistor band colors (especially red/orange and brown/green). Use a multimeter to verify values when in doubt, or buy resistors with printed numeric codes.


LEDs

A light-emitting diode (LED) is a semiconductor diode that emits light when current flows in the forward direction. LEDs are everywhere in embedded projects: status indicators, displays, and lighting.

How it works

An LED contains a p–n junction. When forward-biased (anode positive, cathode negative), electrons and holes recombine at the junction and release energy as photons. The band gap of the semiconductor material determines the light color — and also the forward voltage (VF):

Color Typical VF
Infrared ~1.1 V
Red ~1.7–1.9 V
Green ~2.0–2.2 V
Blue / white ~2.8–3.6 V

White LEDs are typically blue LEDs with a phosphor layer that converts part of the blue light to yellow, producing a white appearance.

Electrical characteristics

Unlike a resistor, an LED does not have a fixed resistance. It behaves like a diode with an approximately constant voltage drop. If you connect an LED directly across a voltage source without limiting the current, the current can rise sharply and destroy the LED.

Always use a current-limiting resistor (or a proper constant-current driver):

1
R = (Vsupply − VLED) / I

Example: Red LED, VLED = 1.6 V, I = 20 mA, supply 5 V:

1
R = (5.0 − 1.6) / 0.02 = 170 Ω  →  use 180 Ω

At 3.3 V with the same LED: R ≈ 85 Ω → use 100 Ω.

Polarity and identification

  • Anode (+): longer leg, connects toward the positive supply (through the resistor).
  • Cathode (−): shorter leg, flat side of the plastic rim, connects to ground.

Standard through-hole indicator LEDs are often rated for 20 mA continuous current. Many tolerate brief higher pulses — which is why PWM (pulse-width modulation) dimming works: the average current stays safe while the perceived brightness changes.

Types you will encounter

  • Single-color (3 mm and 5 mm are most common)
  • RGB — three LEDs (red, green, blue) in one package; mix colors additively
  • Bi-color — two LEDs, sometimes reversed polarity on two pins
  • Blinking / addressable — integrated electronics (e.g. WS2812) that handle timing for you

For wiring an LED safely, see the LED section above and Lab tools for prototyping for breadboard practice.


Diodes

A diode is a two-terminal component that conducts current well in one direction ( forward ) and blocks it in the other ( reverse ). Think of it as an electronic one-way valve.

Forward and reverse behavior

In the forward direction, almost no current flows until the voltage exceeds the forward voltage (VF):

Diode type Typical VF
Silicon (general purpose) ~0.6–0.7 V
Schottky ~0.2 V
LED (gallium-based) ~1.4–3.6 V
Germanium ~0.2 V

Above VF, the diode acts like a low resistance. In reverse, only a tiny leakage current flows — until the breakdown voltage is exceeded, which can destroy the diode.

Common diode types

Type Purpose
Rectifier diode Convert AC to pulsating DC; used in power supplies
Zener diode Regulated reverse breakdown — voltage reference and simple regulation
Schottky diode Fast switching, low forward drop — power supplies, signal circuits
Photodiode Generates current when light hits it — light detection
Varicap (varactor) Capacitance varies with reverse voltage — tuning circuits

Bridge rectifier

Four diodes arranged in a bridge (Graetz bridge) rectify both halves of an AC waveform into pulsating DC. You will see this in mains adapters and power-supply boards.

Why this matters for embedded work

  • Reverse polarity protection — a series diode (or MOSFET-based protection) can save your board.
  • Flyback diode — place across inductive loads (relay coils, motors) to absorb voltage spikes when the current is switched off.
  • ESD and clamping — specialized diodes protect sensitive inputs.

The current–voltage relationship of an ideal diode is described by the Shockley diode equation. In practice, you rarely need the formula — but it explains why a small voltage increase above VF can cause a large current increase.


Capacitors

A capacitor stores electrical charge between two conductive plates separated by an insulator (the dielectric). Its ability to store charge is called capacitance (C), measured in farads (F). In embedded circuits you mostly work with microfarads (μF), nanofarads (nF), and picofarads (pF).

What capacitors do

  1. Block DC, pass AC — couple audio or sensor signals while blocking a DC offset.
  2. Smooth voltage — reduce ripple after a rectifier; decouple IC power pins.
  3. Timing — with a resistor, form an RC charge/discharge curve (used in 555 timers and reset circuits).
  4. Filtering — with inductors, build low-pass, high-pass, and band-pass filters.
  5. Energy storage — camera flashes, short high-current pulses.

Capacitance depends on plate area, plate separation, and the dielectric material:

1
C = ε × A / d

Larger area → more capacitance. Larger separation → less capacitance.

Key formulas

Charge and voltage:

1
Q = C × V

Energy stored:

1
E = ½ × C × V²

RC time constant (charging through a resistor):

1
τ = R × C

After one time constant, a charging capacitor reaches ~63% of the supply voltage; after 5τ it is effectively fully charged.

DC vs AC behavior

  • DC: A capacitor charges until the voltage matches the supply, then current stops — it blocks steady DC (except leakage).
  • AC: The capacitor repeatedly charges and discharges, so AC appears to pass through. Its impedance decreases as frequency increases.

Capacitor types

Type Characteristics Typical use
Ceramic Small, stable (NP0/C0G) or high capacity (X7R, Y5V) Decoupling, filtering, timing
Film (polypropylene, polyester) Good for audio and AC Filters, coupling
Electrolytic (aluminium) High capacitance, polarized Power-supply smoothing
Tantalum High capacitance in small size, polarized Compact power filtering

Polarized capacitors

Electrolytic and tantalum capacitors have a positive and negative lead. Reversing the voltage can destroy them — sometimes violently. The negative stripe on an aluminium electrolytic marks the negative terminal.

Reading capacitor values

  • Printed code: 104 on a ceramic capacitor means 10 × 10⁴ pF = 100,000 pF = 100 nF.
  • Color bands: Similar to resistors, values in picofarads.
  • Explicit label: e.g. 470 µF on electrolytics.

Combining capacitors

  • Parallel: capacitances add — Cp = C1 + C2 + …
  • Series: reciprocals add — 1/Cs = 1/C1 + 1/C2 + …

(This is the opposite of resistors — a common source of confusion.)

Parasitic capacitance

Any two conductors close together have some capacitance. Long wires and PCB traces add parasitic capacitance, which can limit how fast signals can switch — relevant at higher frequencies, less so in beginner Arduino projects.


Inductors (coils)

An inductor (or coil) is a wire wound around a core (air, ferrite, or iron). When current flows, it creates a magnetic field. When the current changes, the magnetic field changes and induces a voltage that opposes the change — this is self-induction.

Lenz's law

1
Vind = −L × (dI / dt)

L is inductance, measured in henrys (H). Practical inductors are usually in microhenrys (μH) or millihenrys (mH).

The minus sign means the inductor "fights" changes in current. That is why switching off a relay or motor coil produces a voltage spike — the inductor tries to keep current flowing.

Inductor vs capacitor

Capacitor Inductor
DC behavior Blocks (open circuit when charged) Passes (short circuit ideally)
AC behavior Impedance ↓ as frequency ↑ Impedance ↑ as frequency ↑
Opposes Voltage changes Current changes

Together, inductors and capacitors form LC resonant circuits used in radios and filters.

Applications in embedded systems

  • Filtering — suppress noise from motors, fluorescent lights, and switch-mode supplies.
  • DC–DC converters — store and transfer energy in buck/boost regulators.
  • Solenoids and relays — a coil creates a magnetic field that moves an armature (linear actuator).
  • Motors and speakers — coils convert between electrical and mechanical energy.

Right-hand rule

To remember the relationship between current direction and magnetic field around a wire: curl the fingers of your right hand in the direction of current; your thumb points in the direction of the magnetic field inside the coil.

Real inductors also have series resistance (RL), which limits their performance at high frequencies.


Field-effect transistors (FETs)

A field-effect transistor (FET) is a three-terminal semiconductor device used to amplify or switch signals. Unlike bipolar junction transistors (BJTs), a FET is unipolar — only one type of charge carrier (electrons or holes) carries the main current.

Terminals

Terminal Role
Gate (G) Controls the channel — almost no DC current flows into the gate
Source (S) Current enters/leaves here (analogous to emitter)
Drain (D) Current flows from drain to source when the channel is on

MOSFETs have a fourth bulk/substrate connection, usually tied internally to the source.

Main types

Type Description
JFET Junction FET — gate separated from channel by a p–n junction
MOSFET Gate isolated by a thin oxide layer — dominates modern electronics

MOSFETs come in n-channel and p-channel variants, and in enhancement mode (normally off; gate voltage turns them on) and depletion mode (normally on).

Operating regions

  1. Cutoff — gate voltage below threshold; channel is off; no significant drain current.
  2. Linear (ohmic) — low drain–source voltage; behaves like a voltage-controlled resistor (used for analog attenuation).
  3. Saturation — higher drain–source voltage; behaves like a current source; used in amplifiers.

For embedded switching (driving motors, heaters, high-power LEDs), you typically use a MOSFET as a low on-resistance switch. Modern power MOSFETs can have drain–source resistances of milliohms, so they dissipate little power when fully on.

FET vs BJT (quick comparison)

FET BJT
Control Voltage on gate Current into base
Gate/base current ~zero (MOSFET) Significant base current
Switching speed Fast Moderate
ESD sensitivity High (especially MOSFETs) Moderate

Why FETs matter to you

  • GPIO cannot drive everything — motors, solenoids, and high-current LEDs need a switching transistor or MOSFET.
  • CMOS logic — the ESP32, Arduino, and virtually all modern ICs are built from MOSFETs.
  • H-bridges and motor drivers — often implemented with MOSFET arrays (e.g. DRV8833, L298N with BJTs or MOSFETs).

ESD damage

MOSFET gates are extremely high impedance. Static electricity on your fingers can exceed the gate oxide breakdown voltage and destroy the device before you notice. Use anti-static precautions when handling bare MOSFETs, and never leave gate pins floating in a prototype — use a pull-down resistor.


Putting it together: a minimal LED circuit

A typical embedded output circuit combines several concepts from this article:

flowchart LR MCU["GPIO pin"] --> R["220 Ω resistor"] R --> LED["LED anode"] LED --> GND["GND"]
  1. The GPIO provides voltage (3.3 V when HIGH).
  2. The resistor limits current per Ohm's law.
  3. The LED (a specialized diode) drops ~1.8–2.0 V and emits light.
  4. A decoupling capacitor (100 nF) near the microcontroller's power pins filters supply noise — a practice you should adopt on every board.

Relevant topics


Videos — other ways to learn

Resistors

What is a resistor?

Capacitors

Capacitors Explained - The basics how capacitors work


Starting points

  1. Review Ohm's law with a multimeter: measure voltage across and current through a known resistor; confirm V = I × R.
  2. Decode three resistors using color bands, then verify with a multimeter.
  3. Build a blinking LED on a breadboard with a current-limiting resistor — use Lab tools for prototyping.
  4. Calculate the resistor for your LED and supply voltage using R = (Vsupply − VLED) / I.
  5. Add a push button and observe how the GPIO reads HIGH/LOW — then read Debouncing inputs.
  6. Identify components on a discarded PCB or in your kit: resistors, capacitors, diodes, voltage regulator, crystal — match each to the sections above.

Focus points

  • Never connect an LED directly to a voltage source without a current-limiting resistor or constant-current driver.
  • Respect polarity on LEDs, electrolytic capacitors, and diodes. Reversing them usually means they simply do not work — but electrolytics can fail dangerously.
  • Use the correct supply voltage. ESP32 GPIO and logic are 3.3 V; connecting 5 V to a GPIO pin can damage the chip.
  • Common ground — all parts of a circuit must share the same ground reference.
  • Inductive loads need protection. When switching relays, solenoids, or motors, use a flyback diode (or a driver IC that includes one) to protect your transistor and microcontroller.
  • Decouple IC power pins with a 100 nF ceramic capacitor close to the chip, plus a larger electrolytic (10–100 µF) on the board's power input for boards with motors or radios.
  • Verify resistor and capacitor values with a multimeter when color codes are ambiguous.
  • Handle MOSFETs with care — avoid static discharge; use gate pull resistors; check whether you need a logic-level MOSFET (fully on at 3.3 V gate drive).
  • Power budget — sum the current drawn by all components. The ESP32's onboard regulator cannot power motors or many LEDs; use a separate supply for heavy loads and tie grounds together.

Key points

  • Ohm's law (V = I × R) is the foundation for calculating currents and choosing resistor values.
  • Resistor color codes encode value and tolerance; when unsure, measure.
  • LEDs are diodes with a forward voltage that depends on color; always limit the current.
  • Diodes conduct one way and are used for rectification, protection, and clamping.
  • Capacitors store charge, block DC, and smooth or couple AC signals; mind polarity on electrolytics.
  • Inductors oppose changes in current and cause voltage spikes when switched off — protect your circuits.
  • FETs switch and amplify with voltage control; they are the building blocks of modern microcontrollers and motor drivers.