Arduino First Step
Enviado por bayaguanero • 6 de Octubre de 2013 • 249 Palabras (1 Páginas) • 235 Visitas
Understanding the Arduino Software
In this chapter, we will discuss the various programming components that will be used throughout this book. If you have programmed in C, you will find that programming for the Arduino is very similar. If not, this chapter will teach you the basic concepts. Why is it important for you to learn the basics of programming the Arduino? In the long run, this will help keep your code clean and readable. Also, learning the basic loops and structures initially will allow us to focus more on the libraries later. Libraries can be sets of classes, types, or functions and can be called by using keywords in your program. The purpose of a library is to readily add more functionality to your program by using code that has been created previously; this promotes code reuse. The libraries we will go over briefly in this chapter are NewSoftwareSerial, LCD Library, TinyGPS, and a few others.
Getting Started with setup() and loop()
All Arduino programs must have two main components to work properly—setup() and loop()—and they are implemented like this:
// Basic Arduino Program
void setup()
{
// Set up I/Os here
}
void loop()
{
// Do something
}
setup() is used to set up your I/O ports such as LEDs, sensors, motors, and serial ports. Careful setup is important because in order to use the pins on the Arduino, we need to tell Arduino that they are going to be used.
...