Results for “Arduino / C”
Small, practical examples. Search by task or narrow things down below.
Control an LED from a button
Translate an active-low button input into an LED output.
button✓ Tested
Count a falling edge with an interrupt
Increment a counter when an external input changes.
attachInterrupt✓ Tested
Debounce a button with a stable-time check
Accept an input change only after it stays stable for 30 ms.
debounce✓ Tested
Measure a short delay with micros
Measure elapsed microseconds around a short operation.
micros✓ Tested
Print a floating-point value with fixed precision
Choose the number of decimal places in serial output.
float✓ Tested
Read one character from serial input
Wait for an incoming byte without blocking the main loop.
Serial.available✓ Tested
Repeat an action a fixed number of times
Use a counter and delay for a simple finite sequence.
for loop✓ Tested
Set and inspect a bit flag
Store several boolean states in one byte.
bitSet✓ Tested
Average a fixed set of readings
Accumulate sample values without overflowing a 16-bit total.
array✓ Tested
Limit a value to a safe interval
Clamp an integer between chosen endpoints.
constrain✓ Tested
Map an input range to an output range
Scale an integer reading to a different interval.
map✓ Tested
Blink the built-in LED three times
Alternate the built-in LED with a short blocking delay.
blink✓ Tested