From 8a6d72aa503869cfd638114c8bb1f525a7d59e4b Mon Sep 17 00:00:00 2001 From: David Montero Crespo Date: Sun, 17 May 2026 23:27:40 -0300 Subject: [PATCH] =?UTF-8?q?fix(editor):=20default=20Blink=20circuit=20need?= =?UTF-8?q?s=20a=20series=20220=CE=A9=20resistor?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The default canvas (Arduino Uno + LED on pin 13) wired the LED directly between pin 13 and GND. Two consequences: 1. Real-world: that's a short across a forward-biased diode, blowing the LED in seconds. 2. Simulator: ngspice can't find a steady-state branch current for an unprotected diode (returns NaN / indeterminate), so the LED visual never lights up. Only the wokwi-arduino-uno element's BUILT-IN LED (rendered internally by the element, not via wire+pinManager) was visible. Fix: insert a 220Ω resistor between pin 13 and the LED anode, cathode straight to GND. Same circuit every introductory Arduino book teaches. SPICE converges, LED blinks visually on the canvas. Reported by a user trying Blink on a fresh /editor visit. --- frontend/src/store/useSimulatorStore.ts | 31 +++++++++++++++++++++---- 1 file changed, 27 insertions(+), 4 deletions(-) diff --git a/frontend/src/store/useSimulatorStore.ts b/frontend/src/store/useSimulatorStore.ts index e33de6d1..995eb131 100644 --- a/frontend/src/store/useSimulatorStore.ts +++ b/frontend/src/store/useSimulatorStore.ts @@ -1888,28 +1888,51 @@ export const useSimulatorStore = create((set, get) => { }, // ── Components ──────────────────────────────────────────────────────── + // Default canvas shown on a bare /editor visit: an external LED on + // pin 13 PROTECTED BY A 220Ω SERIES RESISTOR (the canonical Blink + // wiring textbooks teach). Without the resistor the LED is a direct + // short forward-biased between 5V and GND — real hardware blows the + // diode, and the ngspice solver returns an indeterminate / NaN branch + // current so the visual LED never lights up on the canvas either. components: [ { id: 'led-builtin', metadataId: 'led', - x: 350, + x: 380, y: 100, properties: { color: 'red' }, }, + { + id: 'r-builtin', + metadataId: 'resistor', + x: 240, + y: 130, + properties: { value: '220' }, + }, ], wires: [ + // Pin 13 → resistor pin 1 (current-limiting side). + { + id: 'wire-builtin-pin13', + start: { componentId: 'arduino-uno', pinName: '13', x: 0, y: 0 }, + end: { componentId: 'r-builtin', pinName: '1', x: 0, y: 0 }, + waypoints: [], + color: '#22c55e', + }, + // Resistor pin 2 → LED anode. { id: 'wire-builtin-anode', - start: { componentId: 'arduino-uno', pinName: '13', x: 0, y: 0 }, + start: { componentId: 'r-builtin', pinName: '2', x: 0, y: 0 }, end: { componentId: 'led-builtin', pinName: 'A', x: 0, y: 0 }, waypoints: [], color: '#22c55e', }, + // LED cathode → GND. { id: 'wire-builtin-cathode', - start: { componentId: 'arduino-uno', pinName: 'GND.1', x: 0, y: 0 }, - end: { componentId: 'led-builtin', pinName: 'C', x: 0, y: 0 }, + start: { componentId: 'led-builtin', pinName: 'C', x: 0, y: 0 }, + end: { componentId: 'arduino-uno', pinName: 'GND.1', x: 0, y: 0 }, waypoints: [], color: '#000000', },