Saturday, March 25, 2017

Log2 Library for Arduino

The math.h library for Arduino does not include a log2 function. The log2 library is an Arduino library for using logarithmic calculations with a base of 2.

The usage is straightforward: log2(value) returns a double float of log2 of the input value.

Download the library and examples here:

To install this library, download the .zip file and move the decompressed folder to Documents/Arduino/libraries/.

The example sketch, shown below, returns 1000 Hz as a MIDI note value in the serial monitor.