Building Circuits
Steps & highlighting
Steps drive the assembly walkthrough UI. Each step controls which components are visible, which one is spotlighted, and what input state to display.
type Step = {
title: string;
body: string;
show: string[]; // cumulative — all visible ids at this step
highlight?: string; // id of the component to spotlight
activeInputs?: Record<string, 0|1>; // drives the digital I/O panel
supplyVoltage?: number; // drives analog supply UI
readings?: Record<string, string>; // displays on instruments (e.g. '1.5 V')
ledBrightness?: Record<string, number>; // sets analog LED brightness (0 to 1)
};show — cumulative visibility
show lists every component id that should be visible at this step. It is cumulative — each step's array includes all ids from the previous step plus the new ones. You never shrink it.
steps: [
// Step 1: only the breadboard
{ title: 'Place breadboard', body: '...', show: ['bb'] },
// Step 2: breadboard + XOR gate
{ title: 'Place XOR gate', body: '...', show: ['bb', 'xor1'], highlight: 'xor1' },
// Step 3: everything so far + AND gate
{ title: 'Place AND gate', body: '...', show: ['bb', 'xor1', 'and1'], highlight: 'and1' },
// Last step: all component ids
{ title: 'Test A=1, B=1', body: '...',
show: ['bb', 'xor1', 'and1', 'r_sum', 'led_sum', /* all wires... */],
activeInputs: { A: 1, B: 1 } },
]Every id in a step's show[] must also appear in all subsequent steps. Removing an id mid-sequence makes components pop in and out, which breaks the assembly narrative. Note: When using the CB fluent builder, the show() method handles this cumulative tracking automatically.
highlight — spotlighting a component
The optional highlight field points to one component id. The renderer pulses or accentuates that component to draw the student's attention to what was just added.
- Use it on the step that first introduces a component.
- Point it at a wire to highlight a connection just made.
- In the final "test" step, point it at the LED that should light up.
- Omit it when you're revealing many things at once.
activeInputs — Digital I/O state
The optional activeInputs map drives the input/output display panel, showing which inputs are HIGH or LOW in digital logic experiments.
activeInputs: { A: 1, B: 1 } // both HIGHKeys must exactly match the keys in truthTable.inputs if a truth table is defined.
Analog States: supplyVoltage, readings, ledBrightness
For analog electronics, use the analog-specific fields:
supplyVoltage: Displays the current voltage supplied to the circuit (e.g.5.0).readings: A map of instrumentids to their display strings (e.g.{ vm1: '4.85 V' }).ledBrightness: A map of LEDids to their brightness values from 0.0 to 1.0 (e.g.{ led1: 0.8 }).
{
title: 'Measure Forward Voltage',
body: 'At 5V supply, the diode drops about 0.7V.',
show: [/* ... */],
supplyVoltage: 5,
readings: { dmm1: '0.71 V' },
ledBrightness: { led1: 0.95 },
}Step count guidelines
- Aim for 5–7 steps per circuit.
- First step: always just
['bb']. - Last step:
showcontains every component id including all wires. - Don't split individual wires into separate steps — batch related wires together.
- Do split ICs onto their own steps when explaining their logic function.