An open API service indexing awesome lists of open source software.

https://github.com/jakesmd/fastpin

An Arduino library for safe and high-speed digital read/write operations.
https://github.com/jakesmd/fastpin

arduino arduino-library digitalread digitalwrite

Last synced: 27 days ago
JSON representation

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

Awesome Lists containing this project

README

          

# 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
``` cpp
#include

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](https://www.gammon.com.au/adc).

## 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!