Arduino Essentials

Book description

Enter the world of Arduino and its peripherals and start creating interesting projects

In Detail

The Arduino is an open source microcontroller built on a single circuit board that is capable of receiving sensory input from its environment and controlling interactive physical objects. It is also a development environment that allows you to write software to the board, and is programmed in the Arduino programming language. The Arduino has become the most popular microcontroller platform and thus hundreds of projects are being developed using it, from basic to advanced levels.

This book will first introduce you to the most important board models of the Arduino family. You will then learn to set up the Arduino software environment. Next, you will work with digital and analog inputs and outputs, manage the time precisely, establish serial communications with other devices in your projects, and even control interrupts to make your project more responsive. Finally, you will be presented with a complete real-world example by utilizing all the concepts learned so far in the book. This will enable you to develop your own microcontroller projects.

What You Will Learn

  • Select the correct Arduino board to meet the prerequisites of your project
  • Set up a working Arduino development environment and get to grips with all of its inner workings
  • Work with digital and analog outputs to act on external devices
  • Sense your environment in a digital or analog way by using different types of sensors such as potentiometers, photocells, or thermistors
  • Develop time-based projects that will manage the time in a precise manner
  • Make your project interact with other devices via serial communications
  • Use interrupts to deal with unexpected events
  • Get familiar with a complete real-world project that summarizes all the concepts learned throughout the book

Table of contents

  1. Arduino Essentials
    1. Table of Contents
    2. Arduino Essentials
    3. Credits
    4. About the Author
    5. About the Reviewer
    6. www.PacktPub.com
      1. Support files, eBooks, discount offers, and more
        1. Why subscribe?
        2. Free access for Packt account holders
    7. Preface
      1. What this book covers
      2. What you need for this book
      3. Who this book is for
      4. Conventions
      5. Reader feedback
      6. Customer support
        1. Downloading the example code
        2. Errata
        3. Piracy
        4. Questions
      7. Disclaimer
    8. 1. Meeting the Arduino Family
      1. A game changer
      2. Common features
        1. Arduino Uno
        2. Arduino Mega 2560
        3. Arduino Ethernet
        4. LilyPad Arduino
        5. Arduino Yún
        6. Arduino Mini, Micro, and Nano
        7. Other Arduino family members
          1. Esplora
          2. Arduino Robot
          3. Arduino Due
        8. Unofficial boards
        9. Shields
      3. Just one to rule them all
      4. Users teaching users
      5. Summary
    9. 2. The Arduino Development Environment
      1. A multiplatform tool
      2. Downloading the package
        1. Windows
        2. Mac OS X
        3. Linux
        4. Source code
      3. Installing the software
        1. Windows
        2. Mac OS X
        3. Linux
        4. In case of trouble
      4. Installing the drivers
        1. Windows
        2. Mac OS X
        3. Linux
      5. Running the Arduino development environment for the first time
        1. The toolbar
        2. The code editor
        3. The message area
      6. Preflight checks
      7. Uploading our first sketch
      8. Main menus and commands
      9. The Arduino language
      10. Summary
    10. 3. Interacting with the Environment the Digital Way
      1. Digital versus analog signals
      2. Our first circuit
        1. Using a breadboard
        2. The LED circuit
        3. Circuit schematic
        4. Breadboard connections diagram
        5. Asymmetric blinking code
        6. C language syntax considerations
        7. Troubleshooting faults in the circuit
        8. Dealing with multiple outputs
        9. Current limit per pin
      3. Summary
    11. 4. Controlling Outputs Softly with Analog Outputs
      1. Dealing with analog signals
      2. The analog output circuit
      3. Connections diagram
      4. Analog control through code
        1. The analogWrite() function
        2. The for loop
        3. Complete the fading LED code
      5. Motor control with a transistor
        1. Motor driver
        2. Power source considerations
        3. The complete circuit
        4. Connections diagram
        5. Motor varying speed code
        6. The assembled circuit
        7. Bigger power motors
      6. Summary
    12. 5. Sensing the Real World through Digital Inputs
      1. Sensing by using inputs
      2. Connecting a button as a digital input
      3. The momentary push button
      4. Complete circuit schematic
      5. Breadboard connections diagram
      6. Writing code to react to a press
        1. Configuring and reading a digital input
        2. Taking decisions with conditional bifurcations
      7. Timing and debouncing
      8. Other types of digital sensors
      9. Using an optocoupler as a coin detector
      10. The schematic of the coin detector
      11. The breadboard connections diagram
      12. The complete example code
      13. A real working project
      14. Summary
    13. 6. Analog Inputs to Feel Between All and Nothing
      1. Sensing analog values
      2. The Arduino map function
      3. An ambient light meter
        1. Connecting a variable resistor to Arduino
        2. Voltage divider
      4. An ambient light meter circuit
        1. Breadboard connections
        2. Programming to sense the light
        3. An ambient light meter code
        4. The switch / case control structure
        5. Calibrating the sensor
      5. DC motor speed control revisited
        1. The potentiometer
        2. The motor speed control schematic
        3. The breadboard connections diagram
        4. A simple code to control the motor speed
      6. Summary
    14. 7. Managing the Time Domain
      1. Time control functions
        1. Stopping versus accounting
      2. Making some noise
        1. Arduino library sound functions
        2. Sound hardware connection
          1. Direct connection
          2. Connection through a transistor
        3. A simple timer
          1. Dividing your sketch into different files
          2. Coding a timer by using delays
          3. Coding without delays and blinking an LED while waiting
      3. A bigger project – a metronome
        1. The metronome circuit
        2. The metronome code
      4. Summary
    15. 8. Communicating with Others
      1. Serial communications concepts
        1. The baud rate
      2. Other types of serial communication
      3. Calibrating sensors serially
      4. Sending data to Arduino
      5. A computer connected dial thermometer
        1. The thermometer circuit
        2. The code for the thermometer
      6. Summary
    16. 9. Dealing with Interrupts
      1. The concept of an interruption
        1. The ISR
      2. The tachograph project
        1. Mechanical considerations
        2. A simple interrupt tester
          1. Our first interrupt and its ISR
      3. A dial tachograph
        1. Breadboard connections diagram
        2. The complete tachograph code
        3. Modular development
      4. Summary
    17. 10. Arduino in a Real Case – Greenhouse Control
      1. A greenhouse controller
        1. The controller requirements
        2. Modular design
          1. Temperature control
          2. Humidity control
          3. Lighting control
          4. Manual alarm
        3. Input and output devices
          1. The relay as a mediator
        4. The greenhouse controller circuit
        5. Breadboard connections diagram
      2. The greenhouse controller code
        1. Libraries and constant definitions
        2. Global variables
        3. The interrupt ISR
        4. The alarm routine
        5. Initialization and board configuration
        6. The main execution loop
          1. Temperature subsystem
          2. Humidity subsystem
          3. Lighting subsystem
          4. Alarm subsystem
          5. Serial feedback and calibration
        7. The complete project code
        8. Final considerations
      3. Summary
    18. Index

Product information

  • Title: Arduino Essentials
  • Author(s): Francis Perea
  • Release date: February 2015
  • Publisher(s): Packt Publishing
  • ISBN: 9781784398569