Arduino Development Cookbook

Book description

Over 50 hands-on recipes to quickly build and understand Arduino projects, from the simplest to the most extraordinary

In Detail

The single-chip computer board Arduino is small in size but vast in scope, capable of being used for electronic projects from robotics through to home automation. The most popular embedded platform in the world, Arduino users range from school children to industry experts, all incorporating it into their designs.

Arduino Development Cookbook comprises clear and step-by-step recipes that give you the toolbox of techniques to construct any Arduino project, from the simple to the advanced. Each chapter gives you more essential building blocks for Arduino development, from learning about programming buttons through to operating motors, managing sensors, and controlling displays. Throughout, you'll find tips and tricks to help you troubleshoot your development problems and push your Arduino project to the next level!

What You Will Learn

  • Read data from sensors and take action based on the environment

  • Use the Arduino to turn on lights, write to screens, or play light shows

  • Manipulate motors and other actuators to control the movement of different objects

  • Set up electronic circuits on a breadboard to interact with the Arduino

  • Explore hacks to push your project to the next level

  • Make your projects wireless and make them communicate with the computer

  • Table of contents

    1. Arduino Development Cookbook
      1. Table of Contents
      2. Arduino Development Cookbook
      3. Credits
      4. About the Author
      5. About the Reviewers
      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. Sections
          1. Getting ready
          2. How to do it…
          3. How it works…
          4. There's more…
          5. See also
        5. Conventions
        6. Reader feedback
        7. Customer support
          1. Downloading the example code
          2. Downloading the color images of this book
          3. Errata
          4. Piracy
          5. Questions
      8. 1. Power on – Arduino Basics
        1. Introduction
        2. Downloading the Arduino software
          1. Getting ready
          2. How to do it…
          3. There's more
          4. See also
        3. Connecting Arduino
          1. Getting ready
          2. How to do it…
            1. Mac OS X
            2. Windows
          3. See also
        4. Uploading code to Arduino
          1. Getting ready
          2. How to do it…
          3. How it works…
        5. Learning Arduino code basics
          1. Getting ready
          2. How to do it…
          3. How it works…
          4. See also
        6. Code basics – Arduino C
          1. Getting ready
          2. How to do it…
          3. How it works…
          4. See also
        7. Code basics – Arduino pins
          1. Getting ready
          2. How to do it…
          3. How it works…
      9. 2. Blinking LEDs
        1. Introduction
        2. Blinking LED without delay()
          1. Getting ready
          2. How to do it…
          3. How it works…
            1. Breaking down the code
          4. See also
        3. Connecting an external LED
          1. Getting ready
          2. How to do it…
            1. Schematic
            2. Code
          3. How it works…
            1. Code breakdown
          4. There's more…
            1. LED resistor
            2. Multiple LEDs
          5. See also
        4. Fading the external LED
          1. Getting ready
          2. How to do it…
            1. Schematic
            2. Code
          3. How it works…
            1. Code breakdown
          4. There's more…
          5. See also
        5. RGB LED
          1. Getting ready
          2. How to do it…
            1. Schematic
            2. Code
          3. How it works…
            1. Code breakdown
          4. There's more…
            1. Common anode (+) or common cathode (-)
            2. Without PWM
        6. LED bar graph
          1. Getting ready
          2. How to do it…
            1. Schematic
            2. Code
          3. How it works…
            1. Code breakdown
          4. There's more…
            1. Common anode (+) and common cathode (-)
            2. Bar graph variations
          5. See also
        7. The 7-segment display
          1. Getting ready
          2. How to do it…
            1. Schematic
            2. Code
          3. How it works…
            1. Code breakdown
          4. There's more…
            1. Common anode (+) and common cathode (-)
            2. The dot
            3. Variations
      10. 3. Working with Buttons
        1. Introduction
        2. Connecting a button
          1. Getting ready
          2. How to do it…
            1. Schematic
            2. Code
          3. How it works…
            1. Code breakdown
          4. There's more…
            1. Pull-up configuration
            2. Multiple buttons
          5. See also
        3. Button with no resistor
          1. Getting ready
          2. How to do it…
            1. Schematic
            2. Code
          3. How it works…
            1. Code breakdown
          4. There's more…
            1. Multiple buttons
          5. See also
        4. The toggle switch
          1. Getting ready
          2. How to do it…
            1. Schematic
            2. Code
          3. How it works…
            1. Code breakdown
          4. There's more…
          5. See also
        5. Button to serial
          1. Getting ready
          2. How to do it…
            1. Code
          3. How it works…
            1. Code breakdown
          4. There's more…
        6. Button debouncing
          1. Getting ready
          2. How to do it…
            1. Code
          3. How it works…
            1. Code breakdown
          4. See also
        7. 1,000 buttons to 1 pin
          1. Getting ready
          2. How to do it…
            1. Schematic
            2. Code
          3. How it works…
            1. Code breakdown
          4. There's more…
            1. More buttons
            2. Finding each button
            3. Pressing multiple buttons
          5. See also
        8. Button multiplexing
          1. Getting ready
          2. How to do it…
            1. Schematic
            2. Code
          3. How it works…
            1. Code breakdown
          4. There's more…
            1. More buttons
          5. See also
      11. 4. Sensors
        1. Introduction
        2. Simple sensor – potentiometer
          1. Getting ready
          2. How to do it…
            1. Schematic
            2. Code
          3. How it works…
            1. Code breakdown
          4. There's more…
            1. Arduino Due
            2. Analog reference (AREF)
          5. See also
        3. Temperature sensor
          1. Getting ready
          2. How to do it…
            1. Schematic
            2. Code
          3. How it works…
            1. Code breakdown
          4. There's more…
        4. Detecting motion – PIR sensor
          1. Getting ready
          2. How to do it…
            1. Schematic
            2. Code
          3. How it works…
            1. Code breakdown
        5. Measuring distance – infrared and ultrasonic
          1. Getting ready
          2. How to do it…
            1. Schematic
            2. Code
          3. How it works…
            1. Code breakdown
          4. There's more…
          5. See also
        6. Noise reduction
          1. Getting ready
          2. How to do it…
            1. Code
          3. How it works…
            1. Mean filter
            2. Median filter
            3. Main loop()
          4. See also
        7. Accelerometer
          1. Getting ready
          2. How to do it…
            1. Schematic
            2. Code
          3. How it works…
            1. Code breakdown
          4. There's more…
          5. See also
        8. Localization – GPS
          1. Getting ready
          2. How to do it…
            1. Schematic
            2. Code
          3. How it works…
            1. Code breakdown
          4. There's more…
          5. See also
      12. 5. Motor Control
        1. Introduction
        2. Controlling small motors
          1. Getting ready
          2. How to do it…
            1. Schematic
            2. Code
          3. How it works…
            1. There's more…
            2. Multiple motors
            3. Electrical spikes
          4. See also
        3. Controlling motors with transistors
          1. Getting ready
          2. How to do it…
            1. Schematic
            2. Code
          3. How it works…
          4. There's more…
            1. Pull-down resistor
            2. PNP transistors
            3. MOSFETs
            4. Different loads
          5. See also
        4. Controlling speed with PWM
          1. Getting ready
          2. How to do it…
            1. Schematic
            2. Code
          3. How it works…
            1. Code breakdown
          4. There's more…
        5. Spinning motors both ways
          1. Getting ready
          2. How to do it…
            1. Code
          3. How it works…
            1. Code breakdown
          4. There's more…
            1. Control using the direction pin, PWM pin, and brake pin
            2. Control using Input A, Input B, and PWM
            3. Custom-made L293D driver
          5. See also
        6. Servo motor
          1. Getting ready
          2. How to do it…
            1. Code
          3. How it works…
            1. Code breakdown
          4. There's more…
            1. Controlling the exact pulse time
            2. More servos
            3. Continuous rotation servos
          5. See also
        7. Stepper motor
          1. Getting ready
          2. How to do it…
            1. Schematic
            2. Code
          3. How it works…
            1. Code breakdown
          4. There's more…
            1. Transistor unipolar stepper driver
            2. Identifying the stepper motor type
          5. See also
        8. Bipolar stepper motors
          1. Getting ready
          2. How to do it…
            1. Code
          3. How it works…
            1. Code breakdown
          4. There's more…
        9. Brushless motors
          1. Getting ready
          2. How to do it…
            1. Code
          3. How it works…
            1. Code breakdown
          4. See also
      13. 6. More Output Devices
        1. Introduction
        2. Creating sound
          1. Getting ready
          2. How to do it…
            1. Schematic
            2. Code
          3. How it works…
            1. Code breakdown
          4. There's more…
            1. Tone with no duration
            2. Tone on multiple pins
          5. See also
        3. Transistor driver
          1. Getting ready
          2. How to do it…
            1. Schematic
            2. Code
          3. How it works…
          4. See also
        4. Relay driver
          1. Getting ready
          2. How to do it…
            1. Schematic
            2. Code
          3. How it works…
        5. Optocouplers/Optoisolators
          1. Getting ready
          2. How to do it…
            1. Schematic
            2. Code
          3. How it works…
        6. More outputs – shift registers
          1. Getting ready
          2. How to do it…
            1. Schematic
            2. Code
          3. How it works…
            1. Code breakdown
      14. 7. Digital Communication with Arduino
        1. Introduction
        2. Serial output
          1. Getting ready
          2. How to do it…
          3. How it works…
            1. Code breakdown
          4. See also
        3. Controlling the Arduino over serial
          1. Getting ready
          2. How to do it…
          3. How it works…
          4. There's more…
            1. Arduino Mega
            2. Transmitting values to Arduino
          5. See also
        4. Software serial and UART between Arduinos
          1. Getting ready
          2. How to do it…
            1. Schematic
            2. Code
          3. How it works…
            1. Code breakdown
          4. There's more…
            1. Usable pins
            2. More software serial connections
            3. Interference
            4. General connection tips
          5. See also
        5. Wireless serial
          1. Getting ready
          2. How to do it…
            1. Schematic
          3. How it works…
          4. There's more…
          5. See also
        6. I2C between Arduinos
          1. Getting ready
          2. How to do it…
            1. Schematic
            2. Code
          3. How it works…
            1. Code breakdown
          4. There's more…
            1. Comparing different Arduino categories
            2. More about I2C
            3. Connecting more devices
          5. See also
        7. SD cards
          1. Getting ready
          2. How to do it…
            1. Code
          3. How it works…
            1. Code breakdown
          4. There's more…
        8. LCD character displays
          1. Getting ready
          2. How to do it…
            1. Code
          3. How it works…
            1. Code breakdown
          4. There's more…
        9. Ethernet
          1. Getting ready
          2. How to do it…
            1. Code
            2. How to test
          3. How it works…
            1. Code breakdown
          4. There's more…
          5. See also
      15. 8. Hacking
        1. Introduction
        2. More digital pins
          1. Getting ready
          2. How to do it…
          3. How it works…
        3. Faster PWM
          1. Getting ready
          2. How to do it…
          3. How it works…
            1. Timer 0
            2. Timer 1
            3. Timer 2
          4. There's more…
            1. Interference
            2. Other Arduinos
          5. See also
        4. Storing data internally – EEPROM
          1. Getting ready
          2. How to do it…
          3. How it works…
            1. Code breakdown
        5. Timing Arduino code
          1. Getting ready
          2. How to do it…
          3. How it works…
        6. External interrupts
          1. Getting ready
          2. How to do it…
            1. Schematic
            2. Code
          3. How it works…
            1. Code breakdown
          4. There's more…
            1. Interrupts on various Arduinos
            2. About interrupt-attached functions
            3. Different triggering modes
            4. Detaching an interrupt
      16. A. Electronics – the Basics
        1. Working of electric current
        2. Ohm's law
          1. Resistor configurations
        3. Diodes and LEDs
          1. Diodes
          2. LEDs
        4. Working with breadboards
      17. Index

    Product information

    • Title: Arduino Development Cookbook
    • Author(s): Cornel Amariei
    • Release date: April 2015
    • Publisher(s): Packt Publishing
    • ISBN: 9781783982943