Chapter 3. Controlling the Arduino from the iPad

In the previous chapter, we passed messages back and forth between the Arduino and the iPhone using the Redpark Serial Cable and the SDK. Now let’s make the Arduino do something other than sending messages, and turn some LEDs on and off directly from our iPad.

An Arduino on Your iPad

We’re going to go ahead and build a simple application for the iPad that will let you pull an arbitrary pin on the Arduino HIGH or set it LOW. While we’ll be building the application for the iPad, because I want to take advantage of all that screen real estate, the code will run just fine on the iPhone (or the iPod touch) if you want to build it as an application for the iPhone without any modification.

Open Xcode, choose to create a new project, select a View-based application for the iPad device family, and when prompted name it “Paduino” and save it to the Desktop. When the project opens, deselect Landscape Left and Landscape Right as supported orientations. We’re going to be working in portrait mode.

Adding the Serial Library

This time, let’s start by adding the Redpark library. Open up your copy of the Redpark Serial SDK, grab the redparkSerial.h and rscMgr.h header files from the inc/ folder and the libRscMgrUniv.a static libraries from lib/, and then drag and drop them into your new Paduino project, remembering to tick the “Copy items into destination group’s folder (if needed)” checkbox when prompted.

We also need to add the External ...

Get iOS Sensor Apps with Arduino now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.