Engineering Code Lab · JavaScript in your browser
Code that measures, filters and controls.
32 short programming problems pulled straight from engineering: average a sensor, debounce a button, find a root, tune a PID loop, fit a calibration line. Each has starter code, automated tests (some hidden), hints that unlock one at a time, and an explanation once you solve it.
How the sandbox keeps you safe
- runs in your browserNever on a server.
- no networkThe sandbox cannot fetch, post or open sockets.
- 3 s limitInfinite loops are stopped, not frozen.
- nothing uploadedDrafts stay in this browser.
Every exercise, by level
10 exercises also come as a buggy version to fix: guided debugging, the way real engineering often starts.
Levels describe what you can already do, not your age.
Level 1 · Explorer
- ◇ L1 · SensorsAverage a sensorAdd up a list of temperature readings with a loop and divide to get the mean.loops🐞 debug variant
- ◇ L1 · SensorsFind the spikesScan a vibration log and report the positions of readings above a safe limit.loops and conditions
- ◇ L1 · SensorsMinimum, maximum, rangeTrack the lowest and highest readings in one pass and return them in an object.loops and objects🐞 debug variant
- ◇ L1 · ElectronicsOhm's law calculatorTurn volts and ohms into amps and watts, then print power with sensible units.functions
- ◇ L1 · SensorsADC counts to °CConvert a 10-bit analogue reading from a TMP36 temperature sensor into degrees Celsius.arithmetic
- ◇ L1 · ElectronicsSeries and parallel resistorsCombine a list of resistors in series and in parallel.loops over arrays
- ◇ L1 · PowerHow long will the battery last?Estimate a robot's runtime from battery capacity and load current, with a safety margin.functions and edge cases
Level 2 · Builder
- △ L2 · Digital electronicsBinary ↔ decimal converterConvert between binary strings and numbers the way a microcontroller register works.place value and loops🐞 debug variant
- △ L2 · Motor controlPWM duty-cycle tableBuild a table of pulse on-times for a PWM signal and plot it.loops building arraysplots
- △ L2 · Embedded systemsSet, clear and test register bitsTurn individual bits of an 8-bit control register on and off without disturbing the others.bitwise operators🐞 debug variant
- △ L2 · CommunicationsCheck a sensor packetCompute an 8-bit checksum and reject corrupted radio packets.modular arithmetic
- △ L2 · Embedded systemsDebounce a noisy buttonClean up a bouncing push-button signal so one press counts as one press.state and counters🐞 debug variantplots
- △ L2 · RoboticsWheel speed from an encoderTurn encoder ticks counted over a time window into rpm and metres per second.unit conversion
Level 3 · Innovator
- ○ L3 · Signal processingMoving-average filterSmooth a noisy signal by averaging a window that slides along it, then plot both.sliding windows🐞 debug variantplots
- ○ L3 · Signal processingMedian filter for glitchesRemove one-sample glitches from a distance sensor with a three-point median.sorting small arraysplots
- ○ L3 · Control systemsTraffic-light state machineModel a traffic light as states, transitions and timers, with a safe default.state machines🐞 debug variant
- ○ L3 · ManufacturingSort parts by weightOrder a parts list by mass and count how many comparisons insertion sort makes; watch it step by step.sorting and counting comparisonsvisualiser
- ○ L3 · ElectronicsBinary search a resistor seriesFind a value in the sorted E12 resistor series by halving the search range, and count the probes.binary searchvisualiser
- ○ L3 · SensorsThermistor lookup tableRead between the rows of a datasheet table with linear interpolation and clamp outside it.linear interpolationplots
- ○ L3 · PowerCoulomb countingTrack a battery's state of charge by integrating current over time, clamped to 0–100 %.accumulating over timeplots
Level 4 · Systems Engineer
- □ L4 · Numerical methodsBisection root finderSolve f(x) = 0 for a polynomial by repeatedly halving an interval that contains the root.iteration to a tolerance🐞 debug variant
- □ L4 · MechanicsEuler integration of a falling objectStep a falling object's velocity forward in time with air drag and watch it approach terminal velocity.numerical integrationplots
- □ L4 · Control systemsPID step responseSimulate a PID controller driving a first-order system and see why integral action removes steady-state error.feedback loopsplots
- □ L4 · MeasurementCalibrate with a least-squares lineFit the best straight line through noisy calibration data for a load cell.statisticsplots
- □ L4 · Computer systemsCount cache hitsSimulate a small least-recently-used cache and count hits and misses for a stream of requests.simulation with arrays🐞 debug variant
- □ L4 · RoboticsCheapest path across a gridFind the lowest energy route for a rover across a terrain grid, moving only right or down.dynamic programming🐞 debug variant
- □ L4 · CommunicationsHamming(7,4) error correctionEncode four data bits with three parity bits, then find and fix a single flipped bit.parity and XOR
Level 5 · Research Engineer
- ✦ L5 · SimulationMonte Carlo with a seeded RNGEstimate π by throwing random points at a square, using a seeded generator so results are reproducible.randomness and reproducibilityseeded RNGplots
- ✦ L5 · EstimationA one-dimensional Kalman filterFuse noisy thermometer readings into a steadier estimate that knows how uncertain it is.recursive estimationplots
- ✦ L5 · Signal processingFind the vibration frequencyCompute a DFT magnitude spectrum and report the dominant vibration frequency of a motor.discrete Fourier transformplots
- ✦ L5 · RoboticsShortest route for a delivery robotUse Dijkstra's algorithm to find the cheapest route between rooms connected by corridors.graph algorithms
- ✦ L5 · Numerical methodsHow accurate is your solver?Compare Euler and fourth-order Runge–Kutta on exponential decay against the exact answer.error analysisplots
How it works
- Write in the editor: Tab indents, Ctrl/⌘ + Enter runs.
- Run to see
console.logoutput, line charts fromplot(xs, ys, "label"), or a step-by-step sorting and searching visualiser. - Check to run the visible and hidden tests. Hidden tests show pass or fail, never the expected answer.
- Stuck? Hints unlock one at a time. Nothing is timed and nothing is ranked.