A SPICE-style solver runs a live schematic: LEDs blink, capacitors charge, current flows.
Every frame solves the circuit with modified nodal analysis: one Kirchhoff current law row per node plus one row per voltage source, reduced by Gaussian elimination dozens of times per frame. Capacitors and inductors become trapezoidal companion models, while diodes, LEDs and NPN transistors (Shockley and Ebers-Moll models) are linearized and re-solved by Newton-Raphson with SPICE-style junction limiting. Nothing is scripted: the astable blinker oscillates because each capacitor really holds the other transistor's base below zero until it recharges. Wire colour is node voltage, the dots move at the real branch current, resistors glow with I squared R, and a two-channel oscilloscope traces the waveforms.
Try it. Pick a preset (blinker, three-phase LED chaser, LC tank, bridge rectifier, blank breadboard) or press 1 to 5. Choose a part from the palette and drag between grid points to place it, click a switch to flip it, and hover any part to read its voltage, current and power. Select a part and use the wheel or +/- to change its value. Space pauses, N single-steps, [ and ] change the speed.
Paste this into Claude Code, Codex or any coding agent to get a simple version running, then take it wherever you like.
Build a small electronic circuit simulator with JavaScript and the HTML canvas element. Put everything in a single index.html file with no libraries or build step, so I can open it directly in a browser.
Start simple:
- Make a canvas that fills the window and stays sharp on high-DPI screens, with a dotted grid. Parts sit between two grid points: wires, resistors, capacitors, batteries and a ground.
- Group grid points joined by wires into nodes (a union-find works well). Ground is node 0 at 0 V.
- Solve the circuit with modified nodal analysis: build a matrix with one row per node (Kirchhoff's current law) plus one row per battery (its fixed voltage), stamp each part into it, and solve with Gaussian elimination.
- Treat each capacitor, for a time step dt, as a conductance C/dt in parallel with a current source that carries its previous voltage. Re-solve every step, about 40 small steps per frame.
- Load an RC circuit: a 9 V battery charging a capacitor through a resistor. Draw wires coloured by node voltage, and show the capacitor voltage as a number.
Once that works, make it beautiful and alive:
- Animate dots along every wire and part at a speed proportional to its current, so you can see current flow and reverse.
- Add LEDs and diodes with the Shockley equation. They are nonlinear, so linearize around the current guess and repeat the solve (Newton-Raphson) until voltages stop changing. Make LEDs glow with their actual current.
- Let me pick a part from a palette and drag between grid points to place it, and click switches to flip them.
- Add a small oscilloscope that plots one node's voltage over time.
Explain the key ideas in short code comments. When you're done, tell me how to open it and suggest three directions I could take it next, such as NPN transistors and a two-transistor blinker that oscillates on its own, an inductor and an LC tank that rings, or an AC source with a bridge rectifier.