← PS-3 · THE BITSY BOARD CHALLENGE

Sensors and headers

YOU WILL BE ABLE TO
  • Justify plug-in headers for moving and exposed parts.
  • Write both header dialects correctly and say which parts use which.
  • Explain TRIG/ECHO ranging and servo PWM at block level.
  • Connect rule 5's enforcement to these exact ports.

Two subsystems on the Bitsy are not soldered down: the distance eyes and the servo arm plug into headers. That is a design decision with three reasons. Moving parts and exposed parts BREAK — a header turns a broken sensor into a swap instead of a rework. They are the expensive parts — one classroom board serves many sensors. And they are the parts students handle — a header is the mechanically honest interface for hands.

The distance eyes port is four pins for an ultrasonic ranger: VCC, TRIG, ECHO, GND. The MCU raises TRIG, the module chirps at 40 kHz, and ECHO goes high for as long as the reflection takes to return — distance is time-of-flight, read on GP2, triggered on GP3. The servo port is three pins — SIG, VCC, GND — and SIG carries PWM: a pulse every 20 ms whose width, 1 to 2 ms, commands the arm's angle. Any GPIO can source that PWM on this MCU, which is exactly why the old rule 5 clause about PWM-capable pins needed no validator.

These two ports are also the LEGACY DIALECT you met in PS-1: their pins maps name the rails literally — "VCC": "3V3", "GND": "GND" — documenting the connector's physical pin order. The newer parts wire rails silently. Since the library grew its required-signals check, BOTH dialects are held to the same standard: omit VCC from a servo header and the validator answers with "J2: header_1x3 requires pins.VCC" — the rule that was once stated-but-unenforced, now doing its job on the exact ports it was written for.

Both dialects, side by side, as two entries of one peripherals array — each valid, each complete:

[
  { "id": "eyes", "part": "header_1x4", "refdes": "J1",
    "pins": { "VCC": "3V3", "TRIG": "GP3", "ECHO": "GP2", "GND": "GND" } },

  { "id": "screen", "part": "header_i2c", "refdes": "J3",
    "pins": { "SDA": "GP4", "SCL": "GP5" } }
]
WORKED EXAMPLE

Dialect translation

  1. Write the servo port entry: "part": "header_1x3", "refdes": "J2", "pins": { "SIG": "GP10", "VCC": "3V3", "GND": "GND" } — three keys, rails named.
  2. Now rewrite it AS IF header_1x3 were a modern auto-rail part: "pins": { "SIG": "GP10" } — one key, rails implied.
  3. The engine accepts only the first. Generate the second and it answers "J2: header_1x3 requires pins.VCC" and "J2: header_1x3 requires pins.GND": the library defines the dialect per part.
  4. The point is reading both, not choosing — the palette writes the right one for you, and you check it.
Legacy: three keys with rails; modern: signals only. Each part speaks one, and the validator knows which.

PRACTICE

Q1

Give the three reasons the sensors ride headers while the LEDs are soldered.

Q2

TRIG on GP3 stays an output and ECHO on GP2 an input. Why must they be two pins rather than one shared line?

Q3

Quote the exact messages for a servo header whose pins map has only SIG.

Q4

A classmate proposes powering a metal-gear servo from the port for a robotics project. Two-sentence verdict.

Sensors and headers · PS-3 · iLearnSTEM Electronics