The snippet library.
Small, practical examples. Search by task or narrow things down below.
Require every bit in a mask
Arduino / C: Masking followed by equality tests whether all required flags are set.
Arduino / C✓ Tested
Reuse an LED action with a function
Arduino / C: Put a short LED sequence in a named function and call it twice.
Arduino / C✓ Tested
Run a first sketch and read serial output
Arduino / C: Run a first sketch and read serial output on an Uno with the Serial Monitor set to 9600 baud.
Arduino / C✓ Tested
Search the stream for a message marker
Arduino / C: find consumes input through a matching marker or until timeout.
Arduino / C✓ Tested
Select a response with switch
Arduino / C: Select a response with switch on an Uno with the Serial Monitor set to 9600 baud.
Arduino / C✓ Tested
Set and inspect a bit flag
Store several boolean states in one byte.
bitSet✓ Tested
Smooth a sequence with an exponential filter
Arduino / C: Blend each sample with the previous filtered value.
Arduino / C✓ Tested
Sort a small array in place
Arduino / C: Insertion sort needs no additional array and is suitable for small datasets.
Arduino / C✓ Tested
Split a writable comma-delimited buffer
Arduino / C: strtok modifies its buffer and returns successive tokens.
Arduino / C✓ Tested
Stop receiving interrupts when a task finishes
Arduino / C: detachInterrupt removes the registered callback.
Arduino / C✓ Tested
Store a bounded null-terminated text setting
Arduino / C: Write a fixed buffer and explicitly terminate the retrieved copy.
Arduino / C✓ Tested
Store a compact configuration record
Arduino / C: Save a struct and retrieve it with the same field layout.
Arduino / C✓ Tested