Examples

There are numerous examples that are included with the Arduino IDE and the Web Editor. These examples are simple sketches that demonstrate the Arduino commands and how to use them. These examples range from the very basic sketches that demonstrate how to read and write digital I/O to more advance sketches that show how to use sensors. While these examples are designed to demonstrate the Arduino commands they can also be used as examples of how to write good code for the Arduino.

To access the examples within the Arduino IDE, click on the File option in the menu bar and then go to the Examples option. You will see a list of categories for the examples that look similar to the following screenshot:

If you go to any of the categories, you will see a list of examples for that categories. If you select an example, such as the DigitalReadSerial example under the Basics category, the code for the example will load in a new window and the sketch will look similar to the following screenshot:

With the Web Editor, to load an example select the Examples option from the menu bar. As with the Arduino IDE we will see the same list of example categories. This list will look similar to the following screenshot:

We can then select any of the categories to see the list of examples. What makes the examples in the Web Editor different from the examples in the Arduino IDE is that most of the examples in the Web Editor also include layout (Fritzing) and schematic diagrams showing how to create a circuit that can be used with the example. For example, if we select the same DigitalReadSerial example that we select in the Arduino IDE, not only will we see the code for the sketch, but we will also see the layout as shown in the following screenshot:

The diagrams that are included with the Web Editor are great for beginners because they show how to build the circuit without having to fully understand the code for the example.

There are numerous external libraries that can be used with the Arduino. Let's take a look at what libraries are.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset