Basic Sensors in iOS: Programming the Accelerometer, Gyroscope, and More

Basic Sensors in iOS: Programming the Accelerometer, Gyroscope, and More

Alasdair Allan

Language: English

Pages: 108

ISBN: 1449308465

Format: PDF / Kindle (mobi) / ePub


What really sets the iPhone apart from laptops and PCs is its use of onboard sensors, including those that are location-enabled. This concise book takes experienced iPhone and Mac developers on a detailed tour of iPhone and iPad hardware by explaining how these sensors work, and what they're capable of doing.

With this book, you'll build sample applications for each sensor, and learn hands-on how to take advantage of the data each sensor produces. You'll gain valuable experience that you can immediately put to work inside your own iOS applications for the iPhone, iPod touch, and iPad. This book helps you focus on:

  • Camera: learn how to take pictures and video, create video thumbnails, customize video, and save media to the photo album
  • Audio: use the media picker controller and access the iPod music library in your own application, and enable your app to record and play sampled audio
  • Accelerometer: write an application that uses this sensor to determine device orientation
  • Magnetometer: learn how this sensor verifies compass headings
  • Core Motion: use this framework to receive motion data from both the accelerometer and the vibrational gyroscope

    This short book is part of a collection that will, along with new material, be compiled into a larger book, iOS Sensor Programming. The other books in this collection are Augmented Reality in iOS, Geolocation in iOS, and iOS Sensor Apps with Arduino.

  • .net [UK] (July 2015)

    Pro Website Development and Operations: Streamlining DevOps for large-scale websites

    Essential C# 3.0: For .NET Framework 3.5 (1st Edition)

    Software Build Systems: Principles and Experience

    Creating Walkable Places

     

     

     

     

     

     

     

     

     

     

     

    previous chapter. In this example I use an MPMediaPickerController that, via the MPMediaPickerControllerDele gate protocol, returns an MPMediaItemCollection object containing the media items the user has selected. The collection of items can be played using an MPMusicPlayerControl ler object. Lets go ahead and build a simple media player application to illustrate how to use the media picker controller. Open Xcode and start a new View-based Application project, naming it “Audio” when requested.

    or could be, used in applications. It talks about the differences between the hardware platforms. Chapter 2, Using the Camera Walkthrough of how to use the iPhone’s camera for still and video. How to create video thumbnails and customise video. Chapter 3, Using Audio Walkthrough of how to playback iPod media, as well as how to play and record audio on your device. Chapter 4, Using the Accelerometer Walkthrough of how to use the accelerometer, discussion of what is implied with respect to the

    collection of pointers to more advanced material on the topics we covered in the book, and material covering some of those topics that we didn’t manage to talk about in this book. Conventions Used in This Book The following typographical conventions are used in this book: Italic Indicates new terms, URLs, email addresses, filenames, and file extensions. Constant width Used for program listings, as well as within paragraphs to refer to program elements such as variable or function names,

    the Drawing section so that the arrow Determining Device Orientation | 49 Figure 4-7. Adding an arrow image to the Accelerometer project is rendered correctly with a transparent background. Finally, use the “Image” dropdown to select the arrow.png image to be displayed in the UIImageView (see Figure 4-8). Close the Utility Pane and open the Assistant Editor. Control-click and drag from the UIImageView in your View to the arrowImage outlet in the Assistant Editor, as in Figure 4-9, and add an

    an IBOutlet. Since they aren’t going to be used outside the class, there isn’t much point in declaring them as class properties, which you’d do with a Control-click and drag from the element to outside the curly brace. After doing this, the code should look like this: #import @interface GyroscopeViewController : UIViewController { IBOutlet UIProgressView *xBar; IBOutlet UIProgressView *yBar; IBOutlet UIProgressView *zBar; Accessing the Gyroscope | 75 Figure 6-1. The Gyroscope

    Download sample

    Download