An Arduino library for safe and high-speed digital read/write operations.
These stats were generated by running Speed_Text.ino
on an Arduino clone.
The test measures how long it takes for the function to run 1,000 times and calculates the average duration. This process is repeated 1,000 times, and the final result is the average of all these averages. This approach compensates for the ±4 microsecond accuracy limitation of micros()
.
- 1.32 microseconds
- 4.28 times faster than
digitalRead (5.66 microseconds)
- 2.08 microseconds
- 2.36 times faster than
digitalWrite (4.91 microseconds)
#include <FastPin.h>
FastWritePin ledPin(LED_BUILTIN);
FastReadPin buttonPin(2);
void setup() {
ledPin.begin();
buttonPin.begin(true);
}
void loop() {
ledPin.write(buttonPin.read());
delay(50);
}
⚠️ FastPin only disables PWM timers inbegin()
. DO NOT useanalogWrite()
on the same pin.
Analog reads are typically platform-specific operations. Nick Gammon has an excellent article detailing techniques to accelerate analog readings. You can explore it here.
We're open to contributions, especially for improvements in speed and efficiency. Feel free to open issues or pull requests with optimizations, feature requests, or bug reports to help make this project even better. Your input is valuable and appreciated!