O'Reilly logo

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Building iPhone and iPad Electronic Projects

Book Description

Why simply play music or go online when you can use your iPhone or iPad for some really fun projects, such as building a metal detector, hacking a radio control truck, or tracking a model rocket in flight? Learn how to build these and other cool things by using iOS device sensors and inexpensive hardware such as Arduino and a Bluetooth Low Energy (LE) Shield.

This hands-on book shows you how to write simple applications with techBASIC, an Apple-approved development environment that runs on iOS devices. By using code and example programs built into techBASIC, you’ll learn how to write apps directly on your Apple device and have it interact with other hardware.

  • Build a metal detector with the iOS magnetometer
  • Use the HiJack hardware platform to create a plant moisture sensor
  • Put your iPhone on a small rocket to collect acceleration and rotation data
  • Hack a radio control truck with Arduino and Bluetooth LE
  • Create an arcade game with an iPad controller and two iPhone paddles
  • Control a candy machine with an iOS device, a micro servo, and a WiFi connection

Table of Contents

  1. Preface
    1. Conventions Used in This Book
    2. Using Code Examples
    3. Safari® Books Online
    4. How to Contact Us
    5. Acknowledgments
    6. Credits
  2. 1. Getting Familiar with techBASIC and Built-in Sensors
    1. Your Own Tricorder
    2. A Crash Course in techBASIC
      1. techBASIC Sampler
      2. Running Your First Program
      3. Creating a Program
    3. The Accelerometer
  3. 2. Accessing the Other Built-in Sensors
    1. The Gyroscope
      1. Radians or Degrees?
    2. The Magnetometer
    3. Faster Sensor Response
    4. Heading
    5. Location
    6. Your Own Tricorder
  4. 3. Creating a Metal Detector
    1. The iPhone/iPad Magnetometer
    2. The Earth’s Magnetic Field
    3. Using the iPhone or iPad as a Metal Detector
      1. Converting the Magnetometer Sample into a Metal Detector
      2. Using the Metal Detector
    4. Finding Out More
  5. 4. HiJack
    1. What Is HiJack?
    2. Building the Sensor
    3. External Power for HiJack
    4. Hello HiJack
    5. When Things Go Wrong
    6. A Better HiJack Program
    7. For More Information
  6. 5. Creating a Moisture Meter with HiJack
    1. Adding a Moisture Meter to the Tricorder
    2. Assembling the Moisture Meter
    3. Calibration
      1. Collecting the Calibration Data
      2. Moving Datafiles to and from techBASIC
      3. Using the Calibration Data
    4. Better Software
      1. The Complete Moisture Meter Source
  7. 6. Bluetooth Low Energy
    1. What Is Bluetooth Low Energy?
    2. The TI SensorTag
      1. Writing Bluetooth Low Energy Programs
    3. The Accelerometer
      1. What’s an Accelerometer?
      2. Accessing the Accelerometer
      3. Using the Accelerometer
      4. The Source
    4. The Barometer
      1. Accessing the Barometer
      2. The Source
    5. The Gyroscope
      1. Accessing the Gyroscope
      2. Using the Gyroscope
      3. The Source
    6. The Magnetometer
      1. Accessing the Magnetometer
      2. Using the Magnetometer
      3. The Source
    7. The Humidity Sensor (Hygrometer)
      1. Accessing the Hygrometer
      2. The Source
    8. The Thermometer
      1. Accessing the Thermometer
      2. Using the Thermometer
      3. The Source
    9. Further Explorations
  8. 7. Bluetooth Low Energy iPhone Rocket
    1. A Bit of Rocket Science
    2. Parts Lists
      1. ST-1
      2. ST-2
      3. Other Items for Both Rockets
    3. Why Use a SensorTag?
    4. Construction
      1. ST-2: The iPhone/SensorTag Rocket
      2. ST-1: The SensorTag Rocket
    5. The Data Collection Program
    6. SensorTag 8G Software
    7. Flight Tips
      1. Engines
      2. Parachutes
      3. Flight Conditions
      4. Power Up!
    8. The Data
      1. Analyzing the Data
      2. Rocket Data Analysis
      3. Velocity and Altitude
      4. Rotation and Pressure
    9. What We Found
      1. ST-1 Results
      2. ST-2 Results
  9. 8. Hacking a Radio-Controlled Truck with Bluetooth Low Energy and Arduino
    1. Controlling a Truck with BLE
    2. Selecting a Truck
      1. Disassembly
    3. Hacking the Truck
      1. The H Bridge
      2. The TI Chip
      3. Wiring the Complete Circuit
    4. Controlling the Arduino Uno
      1. Installing Arduino
      2. Downloading Firmata
        1. Installing Firmata
    5. The Software
      1. Pulse Width Modulation
        1. State engines
      2. Back to the Software
    6. Start Your Engines!
  10. 9. Peer-to-Peer Bluetooth Low Energy
    1. Bluetooth Low Energy Slave Mode
    2. BLE Chat
      1. Setting Up the Services
      2. Using the Services
  11. 10. Paddles: A Bluetooth Pong Tribute
    1. The Classic Game of Pong
    2. The Paddles Game
    3. The Paddle Software
    4. The Paddles Console Software
  12. 11. WiFi
    1. Worldwide Sensors
      1. HTTP, FTP, and TCP/IP
    2. WiFly
      1. The Circuit
      2. Establishing a Network Connection
      3. Communication with TCP/IP
      4. A Simple Terminal Program
    3. WiFi Arduino
      1. Loading Software onto the Arduino
      2. The Circuit
      3. Communication Using the Terminal Program
  13. 12. WiFi Servos
    1. Servos: They’re Where the Action Is
      1. The Pololu Serial Servo Controller
      2. The Circuit
    2. Halloween Hijinks
      1. The Software
      2. Take It for a Spin
    3. Push and Pull with Servos
    4. Pomp and Circumstance
  14. Index
  15. Colophon
  16. Copyright