Example Code

Control anything with your iPhone

Products and Environment

This section reflects the products and operating system used to create the example.

To download NI software, including the products shown below, visit ni.com/downloads.

    Software

  • LabVIEW

Code and Documents

Attachment

Download All

Overview

This example use an App Sensor Data publishes all of your accelerometer data from your iPhone to UDP. The controls you get are forwards/ Backwards, left/ right. Driving a Mindstorm around the office and controlling webpages (page up/ down, back and forward). but you could also use it to control the mouse or map to keys on the keyboard and play computers games with it.

 

Description

Before I go on to make this vi work you will need to download an app from the app store, Sensor Data. This app comes in at £5.99, which is steep (this is not mine or any of my friends app and I am not benefiting from sales of this app), but once you have this app and combine it with LabVIEW you can do anything!

The App, Sensor Data, publishes all of your accelerometer data from your iPhone to UDP, in fact you can stream this data over UDP. Then using LabVIEW (only 3 Icons, UDP Open, UDP Read and UDP Close) you can stream this data to your PC on your local Wifi.

Once you have this information in your PC you can then start to experiment. This vi, "Control Anything" just looks at the Pitch and Roll of the phone, (if you look in the subVI I am actually taking the Pitch, Roll, Yaw and Compass reading, but only using the Pitch and Roll)

 

Requirements

  • LabVIEW 2012 (or compatible)

 

Steps to Implement or Execute Code

  1. Download the app Sensor Data from the app store, 
  2. Open Sensor Data, select Euler angles and Mag and True heading to make this vi work.
  3. Enter your IP address and select a port number.
  4. Once you are ready to go you press Start Stream in the streaming section. Once you have done this you can then run the vi and colect data.

 

Additional Information or References 

Front Panel
Front Pannel.png

 

 

VI Snippet

133.png

 

NOTE: I have tested the app with an iPhone 4S and it runs fine, except for it crashing every time I sleep my phone. The app is not cheap so please read the app reviews before buying and make your own decision on whether you should buy it or not.

 

**This document has been updated to meet the current required format for the NI Code Exchange.**

Dan Vickers - Applications Engineer UK and Ireland

Example code from the Example Code Exchange in the NI Community is licensed with the MIT license.

Comments
Ihab
Member
Member
on

Hi Dan Vickers,

Thanks for this cool Vi, I am wondering, will it work with my iPad3? will it damage  the ipad? Thanks again.

griff32
Member
Member
on

Hi Dan,

I am trying to use the VI and the Sensor Data exactly as you have described and written it. I seem to always get an Error 56 like the phone and the PC aren't talking. Do you know of anyway to do a simple check to see what is wrong? both the PC and the phone have the same Wi-Fi Network conection. It is an Ad-hoc connection, would this make any difference?

Thanks