How bina-lee/fsr16x16_bnl works
Project type and purpose
• This is an Arduino library project (“FSR16x16_BNL”) whose core function is to read a 16×16 Force-Sensitive Resistor (FSR) matrix using as few MCU GPIO pins as possible.
• It provides multiple hardware configurations (Direct GPIO, DEMUX/MUX, TIMER4, TIMER8) and a unified software API.
File structure
• Top-level:
• library.properties, README.md, LICENSE – library metadata
• src/FSR16x16_BNL.cpp & .h – library implementation
• examples/…/*.ino – usage sketches for each mode
• No backend/frontend subtrees: this is a hardware-centric library.
• No build scripts beyond Arduino’s build process.
Key insights from the README
• Describes four scanning modes (3-pin, Direct 32-pin, MUX/DEMUX 9-pin, TIMER4 5-pin, TIMER8 minimal), each combining counters, decoders/multiplexers, and GPIO.
• Lists seven constructors covering all row/column selection strategies.
• Emphasizes minimal-pin operation via binary counters and analog multiplexers.
• Mentions typical hardware components (74HC590, 74HC154, 74HC161).
Main components
• Software side (on the MCU):
• Arduino core
• FSR16x16_BNL library module (with sub-modules: begin(), read(), get(), print(), clockDelay())
• Hardware side:
• 16×16 FSR sensor matrix
• Row selector (direct GPIO wires or DEMUX or binary counter + DEMUX)
• Column reader (direct GPIO or analog multiplexer or counter + mux)
• Binary counter IC(s) (4-bit TIMER4 or 8-bit TIMER8)
• Decoder/demultiplexer IC (e.g., 74HC154)
• Analog multiplexer IC
• MCU digital pins (clearPin, clockPin, rowPins[], colPins[])
• MCU analog pin (analogPin)
• Optional: Serial link to PC/visualizer
Relationships and interactions
• Digital control lines from MCU → counter(s) (clear, clock) → decoder/demux → row selection lines to FSR matrix.
• Digital selection lines from MCU → multiplexer address pins → analog multiplexer selects one column → analog output → MCU analogPin.
• Library API calls (read()) drive clock pulses and clear signals in correct sequence, then sample analog input N times to build 16×16 dataset.
• Data flow: FSR matrix → analog mux → analogPin → ADC conversion → stored in library buffer → get()/print() → Serial.
Architectural patterns / design principles
• Hardware abstraction: library hides low-level pin toggling and timing.
• Strategy pattern: different scanning modes selected via constructor (polymorphic behavior).
• Finite state sequencing: clear → 16×16 clock pulses → read → repeat.
• Separation of concerns:
• Pin setup & mode configuration (begin())
• Scanning logic (read(), clockDelay())
• Data access & output (get(), print())
Technologies, frameworks, libraries
• Arduino core (C++)
• FSR16x16_BNL (custom sensor-matrix scanning library)
• Standard Arduino functions (pinMode, digitalWrite, analogRead, Serial)
• External IC datasheets: 74HC590, 74HC161, 74HC154, analog mux (e.g., 4051)
Essential detail checklist
• Clear block for Arduino MCU + FSR16x16_BNL module
• Blocks for each external IC (counter, demux, mux)
• Block for 16×16 FSR matrix
• Software flow: begin() → read() → get()/print()