Skip to content

An Arduino library that takes input in degrees and output a string or integer for the 4, 8, 16, or 32 compass headings (like North, South, East, and West).

License

Notifications You must be signed in to change notification settings

DaAwesomeP/arduino-cardinal

Repository files navigation

Cardinal

License GitHub release Github Releases Downloads Gitter chat

Cardinal is an Arduino library that takes input in degrees and output a string or integer for the 4, 8, 16, or 32 compass headings (like North, South, East, and West). It also makes available environment variables for the minimum, maximum, and middle azimuth of all of the 32 directions. It works fantastically when paired with a magnetometer.

Installation

Cardinal is currently compatible with both Arduino 1.0.x and 1.5.x.

Via Arduino IDE Library Manager

Cardinal is in the library manager. From the latest version of the Arduino IDE, go to Sketch > Tools > Include Library > Manage Libraries and search and install the latest release version of Cardinal.

Via the ZIP archive

Download the latest release ZIP from here or the latest testing version from here. Then go to Sketch > Tools > Include Library > Add ZIP Library.

Usage

The first thing to do is to include the library in your sketch. Goes to Sketch > Include Library > Cardinal. The example has everything put to use in it, so I would advice looking there too. You should also take a look at the types at the wiki page here.

Cardinal name

This initializes the class and bind it to a name of your choosing. Just use cardinal and make it simple. You will call the other functions with like name.otherFunction. So, if you choose cardinal, then it would be cardinal.otherFunction.

Example:

Cardinal cardinal;

::getInteger(int type, float inputFloat)

This will take the type that you select and an input float in degrees and about a heading by numbers 1 through 32.

Example:

cardinal.getInteger(3, 190.15);
// returns 18

::getString(int type, float inputFloat)

This will take the type that you select and an input float in degrees and about a heading in text format.

Example:

cardinal.getString(3, 190.15);
// returns SbW

Environment Variables

Environment Variables for the integer id, middle azimuth, minimum degrees, and maximum degrees for all 32 headings are available here.

More Information

I found the rainbow compass image and the table of headings on this Wikipedia page very helpful in understand these directions.

About

An Arduino library that takes input in degrees and output a string or integer for the 4, 8, 16, or 32 compass headings (like North, South, East, and West).

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages