Book Image

Mastering Arduino

By : Jon Hoffman
Book Image

Mastering Arduino

By: Jon Hoffman

Overview of this book

Mastering Arduino is an all-in-one guide to getting the most out of your Arduino. This practical, no-nonsense guide teaches you all of the electronics and programming skills that you need to create advanced Arduino projects. This book is packed full of real-world projects for you to practice on, bringing all of the knowledge in the book together and giving you the skills to build your own robot from the examples in this book. The final two chapters discuss wireless technologies and how they can be used in your projects. The book begins with the basics of electronics, making sure that you understand components, circuits, and prototyping before moving on. It then performs the same function for code, getting you into the Arduino IDE and showing you how to connect the Arduino to a computer and run simple projects on your Arduino. Once the basics are out of the way, the next 10 chapters of the book focus on small projects centered around particular components, such as LCD displays, stepper motors, or voice synthesizers. Each of these chapters will get you familiar with the technology involved, how to build with it, how to program it, and how it can be used in your own projects.
Table of Contents (23 chapters)

Code

We will need to start off by installing two Adafruit libraries. These are the Adafruit GFX Library and the Adafruit PCD8544 Nokia 5110 LCD library. These libraries are installed as we will need to include them and the SPI library. We can do this by adding the following include statements at the beginning of the sketch:

#include <SPI.h>
#include <Adafruit_GFX.h>
#include <Adafruit_PCD8544.h>

We will not want to initiate an instance of the Adafruit_PCD8544 type using the following code:

Adafruit_PCD8544 display = Adafruit_PCD8544(13, 11, 5, 4, 3);

The parameters are the Arduino pin numbers that the CLK, DIN, DC, CE and RST pins respectively are connected too.

In the setup() function, we will want to add the following code to set up the Adafruit_PCD8544 instance:

Serial.begin(9600);

display.begin(); display.setContrast(40);

Now the rest of the code can go in...