Introduction - Arduino Sketches: Tools and Techniques for Programming Wizardry (2015)

Arduino Sketches: Tools and Techniques for Programming Wizardry (2015)


Arduinos have opened up a new world to us. Both makers and professionals use Arduino-based systems to create wonderful and complex devices to help to create fascinating gizmos. From the simplest device that turns on a light when you press a button to advanced 3-D printers, you can use Arduinos in just about every application.

To power all this, Arduinos use sketches—software programs that you design to complete your device. They communicate with the outside world and are logic behind your projects. To assist you, the Arduino environment has libraries—software that you can add as required, depending on your application or the hardware that you add. Each library is explained in this book with examples for each library.

This book introduces you to Arduino sketches, the software routines that you can use and the different libraries available for the different Arduinos that you will encounter.

The Arduino can be your canvas, and your sketch can be your digital masterpiece.

Overview of the Book and Technology

This book covers everything you need to start using Arduinos. It presents the most common Arduinos on the market today, explains how to get your software up and running, and how to program the Arduino, but most important, it explains the Arduino programming languages and the different libraries that you can add to your designs to provide extra functionality. It also gives a primer in electronics to help you in the numerous examples throughout the book.

How This Book Is Organized

This book is designed to give as much information as possible to someone who is starting Arduino programming. It is separated into four parts.

Part I, “Introduction to Arduino,” (Chapters 1–3) gives an overview of Arduinos—where they came from and why they are here to stay. It gives a primer on electronics and C programming, and also goes into the Arduino Language, the common elements that you will use for every project.

Part II, “Standard Libraries,” (Chapters 4–17) is dedicated to the libraries available for every Arduino, that is, the different software components you can include to add functionality and hardware support. Each library is presented in its own chapter, and an example is provided for each library to help you understand its use.

Part III, “Device-Specific Libraries,” (Chapters 18–23) is dedicated to libraries that are specific to different Arduinos; software you can add to a particular Arduino to access hardware or perform specific tasks. Again, each library is presented in its own chapter, and examples are provided.

Part IV, “User Libraries and Shields,” (Chapters 24–26) is all about going even further with your Arduino; it explains how to import user libraries and how to design and distribute your own libraries. It also shows how to create your own shield, an electronic board that you can add to your Arduino to provide even more functionality.

Who Should Read This Book

This book is primarily for makers—people with ideas on how to create amazing applications or automate everyday tasks—and also for developers who want to get into the amazing world of Arduino programming.

Tools You Need

Each chapter has an example, and the exact components needed for that chapter are listed at the beginning of the chapter. To follow every example in this book, you need the following hardware:

· Computer

· USB cable and micro-USB cable

· power supply

· Breadboard with connector cables

· Several Arduinos:

· 2 x Arduino Uno

· Arduino Due

· Arduino Mega 2560

· Arduino Esplora

· Arduino Robot

· Arduino

· SainSmart LCD Shield

· SainSmart Ethernet Shield

· LM35 Temperature Sensor

· SD card

· Arduino GSM Shield

· Adafruit ST7735 TFT breakout board

· Adafruit MAX31855 breakout board

· Type-K thermocouple wire

· Adafruit SI1145 UV Sensor board

· SainSmart Wi-Fi shield

· DHT11 Humidity sensor

· HC-SR04 ultrasonic distance sensor

· HYX-S0009 or equivalent servo motor

· L293D

· bipolar stepper motor

· Red, green, and blue LEDs

· 10-kilohm resistors

· 4.7-kilohm resistors


Arduino development is a fascinating subject, one that opens up a whole new world of possibilities. Arduinos are perfectly suited for learning about embedded development, but also for automating everyday tasks or even making amazing gizmos and contraptions. Throughout this book, you'll find numerous examples about how to create simple devices, providing a hardware schematic to get you started, as well as the sketch to get you up and running.

To get the most out of your sketches, each library is introduced and the different functions are explained. Examples are provided for every library, going through the code line by line so you understand what the sketch does. My hope is that this book will serve as a reference for your new projects. Have fun!