The snippet library.
Small, practical examples. Search by task or narrow things down below.
Store a small unsigned value
Arduino / C: Store a small unsigned value on an Uno with the Serial Monitor set to 9600 baud.
Arduino / C✓ Tested
Store an integer reading
Arduino / C: Store an integer reading on an Uno with the Serial Monitor set to 9600 baud.
Arduino / C✓ Tested
Store and retrieve a multibyte integer
Arduino / C: put and get copy the bytes of a typed value.
Arduino / C✓ Tested
Store samples in a fixed-size ring buffer
Arduino / C: The write position wraps while the storage size stays constant.
Arduino / C✓ Tested
Store several readings in an array
Arduino / C: Store several readings in an array on an Uno with the Serial Monitor set to 9600 baud.
Arduino / C✓ Tested
Toggle a bit with an XOR mask
Arduino / C: XOR flips selected bits and leaves all other bits unchanged.
Arduino / C✓ Tested
Toggle an output using an explicit software state
Arduino / C: Keep the intended output state in a Boolean variable.
Arduino / C✓ Tested
Trim surrounding whitespace from an Arduino String
Arduino / C: String.trim modifies the object in place.
Arduino / C✓ Tested
Turn on the built-in LED
Configure the Uno’s LED pin as an output and drive it high.
LED_BUILTIN✓ Tested
Turn on the LED with a serial command
Arduino / C: Wait for the character 1 in Serial Monitor before turning on the built-in LED.
Arduino / C✓ Tested
Understand setup() and loop()
Arduino / C: See initialization run once and the main loop run repeatedly.
Arduino / C✓ Tested
Use a wider type for a large count
Arduino / C: Use a wider type for a large count on an Uno with the Serial Monitor set to 9600 baud.
Arduino / C✓ Tested