

Serial.println("MMA8452Q Basic Reading Code!") #include "SparkFun_MMA8452Q.h" // Click here to get the library: MMA8452Q accel The MMA8452Q accelerometer Example 1 is shown below. Write examples that are as clean and lightweight as possibleĮxample 1 should do what 90 percent of users want to do - no more, no less. If you have multiple interface types for your library (say I2C and Serial) consider adding subfolders with examples demonstrating the different library methods using the different interfaces. Fewer people will need the AdvancedI2C or TwoSensors examples.

Note that the complexity of the examples should advance. This will make it obvious to the user where to begin (i.e. Use escalating examplesĬreate your examples with the naming convention “Example1_BasicReadings”, “Example2_SetReadRate,” etc. A library should have an example of most, if not all, of the methods in the class. If the user has no other documentation they should be able to use almost all the features of a device by going through all the examples. Read the Arduino style guide to give you a starting point for your examples. Read and follow the Arduino Style Guide for writing examples Be sure you are being as kind to the user as possible with your library.

The Arduino API Style Guide is a great starting point to make users feel comfortable with your library as well as XYZ library. Read and follow the Arduino API Style Guide for writing libraries Please consider them the next time you write a library. This is a compiled list of lessons we've learned along the way that can make a good Arduino library great. SparkFun has written a large number of libraries for Arduino over many years.
