Skip to content
Back to skills

Matlab Guide Hardware Wiring

ASecurity

Guide hardware wiring and circuit debugging for MATLAB-connected boards. Two capabilities: (1) generate beginner-friendly breadboard wiring diagrams and (2) systematically debug hardware circuits when peripherals don't respond despite error-free code. Board-agnostic. Triggers on: wiring diagram, pin diagram, connection guide, breadboard, how to connect, wire up, show connections, servo wiring, sensor wiring, peripheral hookup, pinout, LED not working, sensor not detected, I2C not found, hardw...

  • 1,414 stars
  • 0 votes
  • 0 copies
  • 0 views
  • Added December 5, 2026
ai-agentsgonoderailsawsdebugginggitapi

Works with

  • api

Security analysis

A100/100

Pro scans all 20 files and shows the line behind each finding

Scanned December 5, 2026

npx -y skills add matlab/matlab-agentic-toolkit --skill matlab-guide-hardware-wiring --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Matlab Guide Hardware Wiring?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Matlab Guide Hardware Wiring
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/matlab-matlab-guide-hardware-wiring/badge)](https://www.skillsdirectory.com/skills/matlab-matlab-guide-hardware-wiring)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
name: matlab-guide-hardware-wiring
description: >
  Guide hardware wiring and circuit debugging for MATLAB-connected boards. Two
  capabilities: (1) generate beginner-friendly breadboard wiring diagrams and
  (2) systematically debug hardware circuits when
  peripherals don't respond despite error-free code. Board-agnostic. Triggers on: wiring
  diagram, pin diagram, connection guide, breadboard, how to connect, wire up,
  show connections, servo wiring, sensor wiring, peripheral hookup, pinout,
  LED not working, sensor not detected, I2C not found, hardware not responding,
  nothing happens, peripheral doesn't work, debug circuit, troubleshoot hardware.
  Not for connecting MATLAB to the board (use matlab-connect-arduino), MATLAB
  code errors (use matlab-debug-code), or writing add-on code (use
  matlab-create-custom-arduino-library).
license: https://www.mathworks.com/content/dam/mathworks/license/pmrl/license.md
metadata:
  author: MathWorks
  version: "1.0"
---

# Hardware Wiring & Circuit Debugging Guide

Beginner-friendly breadboard wiring diagrams, and one-step-at-a-time hardware
debugging when MATLAB code runs but the hardware doesn't respond. Written for
users with no electronics experience.

## Supported Boards

Only these boards — the MATLAB Support Package for Arduino Hardware list
(26.1.3, R2026a; older releases support fewer of them). Check the user's board
against it first; don't run MATLAB code for this check.

```text
Uno, UnoR4WiFi, UnoR4Minima, Nano3, Nano33IoT, Nano33BLE, ProMini328_5V,
ProMini328_3V, Mega2560, MegaADK, Due, DigitalSandbox, Leonardo, Micro,
MKR1000, MKR1010, MKRZero, ESP32-WROOM-DevKitV1, ESP32-WROOM-DevKitC,
RaspberryPiPico, RaspberryPiPicoW, NanoESP32, ESP32-S3-DevKitM
```

Map the user's wording to these names ("Arduino Mega" → `Mega2560`). Some
boards connect and draw under different names:

| Board | Name for `arduino(port, board)` | Name for `generateBreadboardDiagram` |
|-------|---------------------------------|--------------------------------------|
| Nano 33 BLE Sense | `Nano33BLE` | `Nano33BLESense` |
| ESP32-WROOM DevKit V1 | `ESP32-WROOM-DevKitV1` | `ESP32WROOMDevKitV1` |
| ESP32-WROOM DevKit C | `ESP32-WROOM-DevKitC` | `ESP32WROOMDevKitC` |
| ESP32-S3 DevKit M | `ESP32-S3-DevKitM` | `ESP32S3DevKitM` |

Only the BLE **Sense** uses `Nano33BLESense`; a plain Nano 33 BLE draws as
`Nano33BLE`. The Sense counts as a Nano 33 BLE, so it is supported.

**Board not in the list → exit the skill.** Tell the user the MATLAB Support
Package for Arduino Hardware doesn't support it, so these wiring and debugging
steps don't apply, and stop. Don't list the supported boards or give a
text-only table. General electronics advice is fine after that; don't run this
workflow's MATLAB steps or draw a diagram.

## When to Use

- **Wiring** — how to connect a peripheral, a wiring/pin diagram, "help me wire this".
- **Debugging** — the MATLAB code runs without error but the hardware doesn't
  respond (LED dark, sensor silent, I2C scan empty). Load
  `references/debugging.md` and follow it.

If unclear, ask: "Is your MATLAB code producing an error, or does it run fine
but the hardware doesn't respond?"

**Debugging, always:**
- **One diagnostic action per reply**, then stop and ask what they saw. No
  second check, no "also check…", no list of later steps.
- **No `arduino` object → ask, don't assume** the board is connected. Ask
  the question from "Never probe hardware" (below) next to the one
  diagnostic step. Never write "I'm assuming it's connected".
- Never say the hardware works until the user confirms what they physically see.

## When Not To Use

MATLAB errors (`matlab-debug-code` — fix code first), connecting to the board
(`matlab-connect-arduino`), custom add-ons
(`matlab-create-custom-arduino-library`), discovering hardware
(`matlab-discover-hardware`), schematic/PCB design, or a board outside the
Supported Boards list.

**Never probe hardware.** Use the board the user names; don't call
`arduino()`, `arduinolist` or `serialportlist` to find or reach it. Ask only if
the board is unknown. If there's no `arduino` object in the workspace, say so
and ask, e.g.: "I don't see an `arduino` object in my MATLAB session — is the
board connected in yours? If not, set it up first with `matlab-connect-arduino`."

## Wiring Workflow

**1. Get the board sheet** — one `evaluate_matlab_code` call (the scripts
folder is next to this file):

```matlab
addpath('<skill folder>/scripts');
getBoardWiringInfo('<Board>', ["<part 1>", "<part 2>"]);
```

It prints logic voltage, layout and counting landmark, power pins and where
their power comes from, I2C/SPI/serial pins (and `SerialPort`), free GPIO, PWM
pins, input-only and avoid pins, board gotchas, where each pin is (`Where:`),
and each part's catalog entry. Use
it instead of reading the registry, pin maps or board guides. A board with no
pin map prints so, plus the table header to use — say there's no pin map, give
that markdown table (`#`, Peripheral Pin, Board Pin, Role, **Wire Color**) with
a voltage warning, orientation and counting, and no diagram.

**2. Choose pins** from the sheet: protocol pins for I2C/SPI/serial, free GPIO
for signals (`PWM:` pins for `writePWMVoltage`), the power pin that matches the
part. Never hardcode pins. `Serial: none` means MATLAB has no serial device —
say so and don't wire TX/RX.
A specific part "not in the parts catalog" (a named model you don't know) → ask
the user for its supply voltage (or check its datasheet) before wiring; don't
guess. A generic part ("an I2C sensor", "a button") isn't a question: wire a
typical breakout from the board's logic-level pin (3V3 on 3.3V boards) and say
what you assumed. Custom add-ons with software
I2C/SPI use the add-on's pins.

**3. Explain in text first — then stop and ask.** Give a table, each row:
part pin → board pin, plain-words role ("SIGNAL", "POWER", "GROUND"), and
**counting** copied from the sheet's `Where:` line ("6th from USB", not just
"D6"); don't work positions out yourself. Mention LED polarity (long leg
+), resistor values, and voltage risks. End with "Want me to generate a visual
wiring diagram?" and **wait for the answer — don't call
`generateBreadboardDiagram` in the same turn.** Skip the question only when the
user explicitly asked for a diagram or visual ("yes, generate the diagram");
"help me wire", "how do I connect" or "which pins" are not diagram requests.
When you do generate, still give the table.

**4. Generate** in the same kind of single call — no helper `.m` files unless
the user asks for a script to keep:

```matlab
peripherals = struct( ...
    'name', {'220 Ohm Resistor', 'LED'}, ...
    'connections', { ...
        struct('peripheralPin', {'Leg 1', 'Leg 2'}, 'boardPin', {'D9', '~'}, ...
            'role', {'signal', 'bridge'}, 'label', {'FROM D9', 'TO LED'}), ...
        struct('peripheralPin', {'Anode (+)', 'Cathode (-)'}, 'boardPin', {'~', 'GND'}, ...
            'role', {'bridge', 'ground'}, 'label', {'FROM RESISTOR', 'GROUND'})});
generateBreadboardDiagram('<Board>', peripherals, 'railPairs', 1, ...
    'warnings', {'<voltage or power note, if any>'});
```

- `label`: short caps words only — `SIGNAL`, `POWER`, `GROUND`, `I2C DATA`,
  `FROM D9`. No wire colors or pin IDs; the diagram adds those.
- `role`: `signal`, `power`, `ground`, `pwm` (servo/ESC control),
  `i2c-sda`, `i2c-scl`, `spi-clk`, `spi-sdo`, `spi-sdi`, `spi-cs`, `spi-dc`,
  `spi-rst`, `bridge`. SPI uses SDO/SDI/SCK/CS everywhere — `peripheralPin`
  names, labels, text and code — even if the module is printed MOSI/MISO/SS
  (MOSI/DIN→SDO, MISO/DOUT→SDI, SS→CS).
- Resistors, LEDs and capacitors are separate peripherals chained with
  `boardPin '~'` (last pin of one, first pin of the next).
- Where three or more parts meet (voltage divider, pull-up), give each of them
  the same board pin, not `'~'`. HC-SR04 ECHO divider: ECHO (its last pin)
  `'~'` → `1k` leg 1 `'~'`, leg 2 `D18`; `2k` leg 1 `D18`, leg 2 `GND`.
- Put a resistor's value in its name (`'4.7k Resistor'`). If the user gave
  none, pick one (LED: 220–330 Ω at 5V, 100–220 Ω at 3.3V; pull-up 4.7k) and
  say you chose it.
- A part not in the catalog gets a `voltage` field (`'5V'`, `'3.3-5V'`); all
  peripherals then need the field (`''` for the rest).
- Pico pins are `GPn` in the diagram but `'Dn'` in MATLAB code.
- Two different supplies (e.g. a 3V3 sensor and a 5V servo) get separate +
  rails automatically: the first on the bottom rail, the second on the top.
  Say which part uses which rail; never join the two + rails.
- The diagram can't draw a separate power supply. When a part needs one (dead
  5V pin on Nano 33 boards, big servos, motors), wire it to the board power
  pin it would use and put the external-supply instruction in `'warnings'`
  and in your text.

The script prints Step 0 (orientation), every numbered wire with its counting
hint and power-source note, any safety checks, and `Wiring diagram saved to:
<path>`. **Relay that output — don't open or parse the HTML.** Tell the user the
full path and that the diagram opened in a MATLAB window. It's saved in
MATLAB's current folder (`tempdir` if that's read-only); pass `'outputDir'` to
choose another.

**A `DANGER:` line** (also a `generateBreadboardDiagram:unsafeWiring` warning)
means the wiring can damage the board or part: 5V signals into a 3.3V board, a
3.3V part on 5V, wrong supply, a motor or relay on a bare GPIO pin, an LED with
no resistor, power wired to GND. Don't call it ready — explain the risk
plainly, offer the fix (3V3 power, level shifter or divider, external supply,
transistor/driver, resistor), and regenerate once they choose.

**5. Verify** — ask whether the diagram matches their parts; adjust and
regenerate if not.

## Rules

- Breadboard diagrams only, always from `generateBreadboardDiagram`. Never
  embed or trace support-package board artwork (`Pinout_*.svg`) — shared output
  has legal constraints.
- `shield` boards (Uno, Uno R4, Leonardo, Mega 2560/ADK, Due) can't plug into a breadboard: they
  sit beside it and wire with male-to-male jumpers. `module` boards (ESP32
  DevKits, MKR) are too wide for one breadboard: they also sit beside it, with
  female-to-male jumpers on their pins. Never say otherwise.
- Read the board's gotchas from the sheet (dead 5V pin on Nano 33 boards,
  input-only ESP32 pins, D0/D1 on Uno-class boards) before choosing pins.

More detail when needed: `references/script-api.md` (script options, output,
and a multi-part struct example),
`references/design-rules.md` (pin-map and registry schema), and the board
guides `references/boards/arduino.md`, `references/boards/esp32.md`,
`references/boards/raspberrypi.md`.

----

Copyright 2026 The MathWorks, Inc.

----

Files in this skill

  • SKILL.md10.6 KB
  • assets/board-registry.json12.1 KB
  • assets/peripherals.json5.9 KB
  • assets/pin-maps/arduino/due.json5.3 KB
  • assets/pin-maps/arduino/leonardo.json2.1 KB
  • assets/pin-maps/arduino/mega2560.json5.2 KB
  • assets/pin-maps/arduino/megaadk.json5.2 KB
  • assets/pin-maps/arduino/micro.json2 KB
  • assets/pin-maps/arduino/mkr1000.json1.8 KB
  • assets/pin-maps/arduino/mkr1010.json1.8 KB
  • assets/pin-maps/arduino/mkrzero.json1.8 KB
  • assets/pin-maps/arduino/nano3.json1.7 KB
  • assets/pin-maps/arduino/nano33ble.json1.9 KB
  • assets/pin-maps/arduino/nano33blesense.json1.9 KB
  • assets/pin-maps/arduino/nano33iot.json1.9 KB
  • assets/pin-maps/arduino/nanoesp32.json1.9 KB
  • assets/pin-maps/arduino/promini328_3v.json1.7 KB
  • assets/pin-maps/arduino/promini328_5v.json1.7 KB
  • assets/pin-maps/arduino/uno.json1.8 KB
  • assets/pin-maps/arduino/unor4minima.json1.9 KB

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

View all in ai-agents →

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.