Skip to content

An Arduino library for safe and high-speed digital read/write operations.

License

Notifications You must be signed in to change notification settings

JakesMD/FastPin

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

FastPin

An Arduino library for safe and high-speed digital read/write operations.

Stats

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().

Read

  • 1.32 microseconds
  • 4.28 times faster than digitalRead (5.66 microseconds)

Write

  • 2.08 microseconds
  • 2.36 times faster than digitalWrite (4.91 microseconds)

Usage

#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 in begin(). DO NOT use analogWrite() on the same pin.

Optimizing Analog Reads for Speed

Analog reads are typically platform-specific operations. Nick Gammon has an excellent article detailing techniques to accelerate analog readings. You can explore it here.

Contributions Welcome

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!

About

An Arduino library for safe and high-speed digital read/write operations.

Topics

Resources

License

Stars

Watchers

Forks

Languages