Home

Awesome

digitalWriteFast

Arduino library for faster digitalWrite() using direct port manipulation and macro for ease in pin assignments. Which actually also does faster pinMode() and digitalRead().

Usage

Include the library: #include <digitalWriteFast.h>

Macro definitions:

Parameters:

In order to toggle fast, all the three parameters above must be constant or defined by the macro for ease in changes during compilation.

For example:

Setting the parameter as a variable would cause the macro to return an error during compilation.

This makes sure digitalWriteFast that produces faster toggling, and notifies the programmer the specific area where toggling is slow. Otherwise, use normal digitalWrite

This is opposed to the forked library form Watterott, where if a variable is used as the parameter, the macro would revert to use sold digitalWrite, and remain undetected.

Speed

The regular digitalWrite() in Arduino Uno core (16MHz) takes about 6280nS while digitalWriteFast() port manipulation takes 125nS.

More info in: /NOTES/NOTES.md

This is a huge difference, especially or timing sensitive applications.

Direct port manipulation is troublesome where one has to refer to the pin assignment of the package and manipulate specific ports, instead of pin numbers on the Arduino board.

This library makes it easier by using digitalWriteFast() and the macro will replace it will the approritate port manipulation commands.

Compatibility

If not in the list, the macro will revert back to digitalWrite(), pinMode() or digitalRead()

Installation

  1. Download the repo as zip, extract and place into Arduino IDE libraries folder.
  2. Rename "digitalWriteFast-master" to "digitalWriteFast" Arduino IDE does not accept dash character.

Reference

Fork of Watterott's https://github.com/watterott/Arduino-Libs/tree/master/digitalWriteFast I just forked the whole repo, and delete unrelated files, I tried sparse checkout and gave up.

Watterott's digitalWriteFast could have used the below links as referrence.