Arduino Pin Library

I created an Arduino library for fast digital I/O using port manipulation supporting the Arduino Mega, Arduino Uno, and Arduino Leonardo. The source code can be found at https://github.com/fenichelar/Pin. Complete documentation can be found at https://pin.fenichelar.com. The library is also avaliable on the Arduino Library Manager. Here are some common uses:

Import Pin Library

#include <Pin.h>

Create Pin Object

Single Pin

Pin myPin = Pin(5);

Array of Pins

Pin myPins[] = {6,7};

Use as Input

Set Mode to Input

myPin.setInput();

Enable/Disable Pullup Resistor

myPin.setPullupOn();
myPin.setPullupOff();

Use as Output

Set Mode to Output

myPin.setOutput();

Set HIGH/LOW

myPin.setHigh();
myPin.setLow();

Get Pin Info

Get Mode (INPUT/OUTPUT)

myPin.getMode();

Get State (HIGH/LOW)

myPin.getState();

Get Value (HIGH/LOW)

myPin.getValue();

Toggle

Toggle Mode (OUTPUT -> INPUT, INPUT -> OUTPUT)

myPin.toggleMode();

Toggle State (HIGH -> LOW, LOW -> HIGH)

myPin.toggleState();
Written on June 23, 2015