Arduino and iOS: example code?

Hey Chris,
I’m looking to connect an ipad running MWorks iOS to a reward pump, via an arduino board. Can you point me towards example code that might do something like this? To clarify, the USB or BLE io-device must be connected to the server (the ipad), not the machine running the client.
Let me know, and thanks!
Rishi

Hi Rishi,

I’m looking to connect an ipad running MWorks iOS to a reward pump, via an arduino board. Can you point me towards example code that might do something like this?

I’ve attached a short example experiment that demonstrates how to set this up on the MWorks side. It configures pin 13 on the Arduino (which is usually connected to a built-in LED) as a digital output line. Once the experiment is running, setting the variable pump_control_line to true or 1 should turn the LED on, and setting it false/0 should turn it off.

On the Arduino side, you need to install the correct firmware. If you want to bring your board to my office, I can do this for you very easily. If you’d prefer to do it yourself, then

  1. If you haven’t already, download and install the latest Arduino IDE.

  2. Download the latest version of the Arduino Firmata library, and install it in $HOME/Documents/Arduino/libraries.

  3. If you’re using an Adafruit Feather M0 Bluefruit LE, download the latest version of the Adafruit_BluefruitLE_nRF51 library, and install in alongside the Firmata library.

  4. Open the Arudino IDE, and select File → Examples → Firmata → StandardFirmataBLE.

  5. If you’re using a Feather M0, in the window that opens, navigate to the tab containing the file bleConfig.h, and change the line

     //#define BLUEFRUIT_LE_SPI
    

    to

     #define BLUEFRUIT_LE_SPI
    

    (In other words, uncomment that line.)

  6. Select your board and port, and build and upload the example as per usual.

Again, I can do this for you, if you prefer.

To clarify, the USB or BLE io-device must be connected to the server (the ipad), not the machine running the client.

Correct. FYI, USB is an option only on a Mac. BLE works with both Macs and iPads.

Chris

Attachment: firmata_ble_example.mwel.zip (356 Bytes)

Hi Rishi & Michael,

FYI, I’ve written a more detailed guide on how to set up a Feather M0 Bluefruit LE. If you have any problems, please let me know.

Chris