FastPins.h
Super fast digital writes, and mode changes to Arduino pins!
Supported Boards:
- Arduino Uno R3 328P
- Arduino Leonardo 32U4
- Arduino Mega 2560
Download FastPins.h
What is FastPins?
Arduino super fast pin I/O
With this header file, you can:
- Set pin to HIGH or LOW in one instruction that typically takes 2 clock cycles
- Set pin mode in 1-2 instructions, 2-4 clock cycles
1 cycle to set OUTPUT
2 cycles to set INPUT
2 cycles to set PULLUP
How do I use the header file?
Add the following code to the top of your main sketch file, substituting your flavor of board in for __FASTPINS_UNO__
#ifndef __FASTPINS_UNO__
#define __FASTPINS_UNO__
#endif
#include <FastPins.h>
Which boards are supported?
Here are the supported Arduino board #defines:
__FASTPINS_UNO__
__FASTPINS_LEONARDO__
__FASTPINS_MEGA2560__
What can I actually do on each pin?
Here's what's included for each pin:
PIN13_MODE_IN; // set pin 13 to INPUT (Arduino default mode). Just like the official code, this sets the pin to LOW
PIN13_MODE_OUT; // set pin 13 to OUTPUT. Doesn't affect current pin value (i.e. HIGH or LOW)
PIN13_MODE_PULLUP; // set pin 13 to INPUT_PULLUP. Just like the official code, this sets the pin to HIGH
PIN13_HIGH; // set pin 13 to HIGH
PIN13_LOW; // set pin 13 to LOW
How do I use the header file?
Here are the pins covered on the supported Arduinos:
- All labeled pins on the board that can be changed, specifically:
- Digital pins
- Analog pins
- SDA, SCL
- SCK, MISO, and MOSI
- Anything else is board specific!
If you want to use a board specific pin, you probably know what you're doing.
It should be defined for your board in the header.
More Information
Arduino Pinouts and other super useful diagrams by PighiXXX.