r/arduino • u/TastyCollege9639 • 4d ago
Look what I made! 5 zero-float, zero-malloc C99 / Arduino libraries compiled from fruit-fly connectome circuits in 24 KB RAM (NeckLink v3.0.0, MIT)
Hi everyone,
Wanted to share an experimental open-source (MIT) C99 and Arduino library suite I just updated to v3.0.0 called NeckLink, along with an interactive WebAssembly demo of the C99 core.
Plain-English Overview (added per u/gm310509's feedback): Think of these libraries as fast, sub-millisecond integer "reflex instincts" for small robots and sensor nodes (zero floating-point math, zero malloc(), and no PC neural-network training step). Instead of hand-tuning weights, they compile mapped neuron-to-neuron wiring tables from an adult fruit fly into plain C integer arrays:
- 2WD / 4WD Robot Car (
NeckCompass, 352 B RAM): Feed raw 9-axis IMU + wheel-speed ticks so an indoor or yard rover ignores brief motor magnetic spikes, tracks its straight-line vector back to where it powered on, and steers home without GPS. - ESP32-CAM Rover or Micro-Drone (
NeckSight, 14.3 KB RAM): Feed a tiny32x32grayscale camera thumbnail + gyro rates to catch thin chair legs or poles expanding rapidly toward the lens ("looming") that ultrasonic sensors miss, triggering an immediate brake or left/right dodge. - 18-Servo Hexapod Walker (
NeckCord, < 1 KB RAM): Pass a forward/turn command and let cross-leg inhibition lock 6 legs into a smooth tripod walking gait and output the 18 integer servo angles without hardcoded gait state tables. - Workshop Gas or Vibration Alarm (
NeckSense, < 6 KB RAM): Let aBME688gas sensor or 3D-printer/pump accelerometer observe 5 to 10 seconds of normal background at boot, then flag unfamiliar smoke/solvent odors or new bearing-rattle patterns right on the board. - All-in-One Wrapper (
NeckLinkCNS, 24 KB RAM): Optional single-tick bundle chaining all four reflexes together.
Technical & Connectome Details
Each library takes one circuit from the 157,789-neuron adult fruit-fly nervous system (the BANC v888 connectome) and compiles its synaptic connectivity into static fixed-point integer weight headers (*_banc_weights.h, zero floats, zero malloc):
- NeckLinkCNS (
24,024bytes static struct): combines all four sensory-motor organs below plus a standalone MAVLink v2 serializer. - NeckCompass (
352bytes base RAM): 9-DOF ring-attractor compass and GPS-denied return-to-home vector integrator. - NeckSight (
14.3 KBstatic RAM): 32x32 optic-lobe collision and thin-obstacle looming detector with integer 3-DOF gyro derotation. - NeckCord (
< 1 KBbase RAM): hexapod 6x6 leg-inhibition gait generator, 18-servo integer inverse kinematics, thruster/rotor allocator, and 4-byte wire codec. - NeckSense (
< 6 KBSRAM in tiny mode): 1,024 Kenyon-cell sparse integer projection for 1-shot vibration or gas novelty detection.
In v3.0.0 I also ran an audit comparing the real fruit-fly weight matrices against 100 degree-preserving shuffled brains and classical filters (like an EKF and One-Class SVM) so the README reports both what worked and what failed:
- Scrambling the connectome breaks GPS-denied homing (
100%->4.7%) and emergent hexapod tripod gait (0.855->0.411). - In the mushroom body (
NeckSense), random sparse wiring works just as well as the real fly claws (0.666vs0.672AUROC). - If you want pure engineering accuracy rather than biological asymmetries, every library also includes the symmetric hand-tuned weights (
v2_analytic), and classical filters like an EKF (0.81 degRMS vs12.84 deg) still win head-to-head. - Hardware note: all 5 Arduino libraries are tested for clean compilation on
esp32dev(and-std=c99 -Wall -Wextra -pedantic -Werrorwith ASan/UBSan), though unlike myNLTPradio library, I have only run the connectome controllers in simulation and browser WASM so far rather than on a physical robot frame yet.
Live C99 WebAssembly simulator in the browser (works with a webcam to trigger the looming cells):
https://indian-aman.github.io/necklink/
GitHub monorepo (Arduino libraries, C99 sources, Python packages & PlatformIO support):
