Author Topic: how to connect your MaKey MaKey to an iPad  (Read 23808 times)

eric

  • Administrator
  • MaKey MaKer
  • Posts: 64
  • I'm Eric, one of the inventors of MaKey MaKey!
    • View Profile
    • my homepage
how to connect your MaKey MaKey to an iPad
« on: July 17, 2013, 03:34:39 PM »
So, I've been wanting to do this for a while. Finally, I've got a MaKey MaKey connected to an iPad, via the Apple Camera Connection Kit. The Camera Connection Kit is a little USB adapter for iPad: http://store.apple.com/us/product/MC531ZM/A/apple-ipad-camera-connection-kit.

Here's a Vine (short looping animation with sound) to show it working:

https://vine.co/v/hmWp3qhqTOL

 I used some code provided by the folks at defitech.ch, but I wanted to document the steps here in case that helps other people.  The main challenges are getting the iPad to recognize the MaKey MaKey through the camera connection kit adapter (this requires reprogramming the MaKey MaKey), and then making the iPad actually do something in response to keypresses (I made a little webpage that plays drum sounds and changes color when you press keys, shown in the Vine above).

STUFF YOU NEED
A MaKey MaKey
an iPad
an Apple Camera Connection Kit

REPROGRAMMING THE MAKEY MAKEY

The basic problem, it turns out, is that there are a couple of USB settings inside the MaKey MaKey that need to be changed for the iPad to recognize it. The kind folks at Defitech provided their code with these changes here (in english at the bottom of the page):

http://www.defitech.ch/handigeek/categories/didacticiel/un-contacteur-pour-ipad-avec-le-makey-makey

I took me a while to figure out how to replicate what they did, so I'll try to explain here more fully. First of all, you will need to reprogram your MaKey MaKey using the Arduino software. If you haven't done this before, unfortunately there are a whole bunch of steps to get this set up, but they are covered in this tutorial: https://www.sparkfun.com/tutorials/388

The critical changes they made are not just in the .ino file, though. The USB settings are in files inside the hardware folder, which they also provide in their download ( https://github.com/defitech/MaKeyMaKey/archive/master.zip ). The hardware folder is what you are choosing when you choose "MaKey MaKey" in the "boards" menu in the Arduino software. So to make sure you use the defitech's modified hardware folder, you have to go the Arduino software's preferences panel, and change the "Sketchbook location." By default, it will point to a folder called "Arduino" in your documents folder. Instead you need to point it to a location inside the defitech download: inside the "firmware" folder, there's an "Arduino" folder, and that's one to choose.

Once you've done this, you should be able to upload defitech's code to your MaKey MaKey. Then if you plug it into your iPad with the Camera Connection Kit, it should work (you can for example open up the notes app and press the spacebar).

BUT! The next time you try to upload code to the MaKey MaKey, it will seem to not work. What you need to do is reset it just before it uploads, by briefly connecting the reset pin ("rst" on the back of the MaKey MaKey) to ground.

If you're interested, here's a diff showing the exact set of changes that defitech made that make this work:
https://github.com/defitech/MaKeyMaKey/compare/sparkfun:master...master

MAKING SOUNDS USING KEYPRESSES ON THE IPAD

The problem, now, is that the iPad doesn't necessarily do anything in response to keypresses, aside from typing. I wanted it to make drum sounds, so I made a little javascript program that runs on a web page, to trigger sounds when you press a key (right now it responds to w,a,s,d,f):

http://web.media.mit.edu/~ericr/audiotest/

The javascript audio libraries I tried (howler and soundmanager2) didn't work on the iPad, so I had to use some lower level code. You can "view source" on that page to see my code.

ALSO TRY BLUETOOTH?

Before doing this, I was able to use Sparkfun's Bluetooth add-on for MaKey MaKey (https://www.sparkfun.com/products/11378) to pair with an iPad.  But this was not as quick and responsive as I wanted, and the pairing process was a bit quirky, so I really wanted to get it connected with a wire.

Good luck! let me know if you have any questions, and please share what you make.

frodroe

  • MaKey MaKer
  • Posts: 1
    • View Profile
Re: how to connect your MaKey MaKey to an iPad
« Reply #1 on: August 06, 2013, 06:21:22 PM »
This works great! Thanks for the script you wrote to try it out.
I'm looking forward to an iOS app that will make GREAT use of the Makey Makey.

Arvicola

  • MaKey MaKer
  • Posts: 1
    • View Profile
Re: how to connect your MaKey MaKey to an iPad
« Reply #2 on: December 06, 2013, 12:19:10 PM »
Has anyone managed to get this working with iOS7? I did get the "Too much power" message to go away but now I get "Cannot Use Device: USB IO Board: The connected device is not supported"

I figured it out eventually. Recording the answers here in case anyone else gets confused by these issues.

Firstly although iOS complains that the device is not supported, it still responds to the keyboard input. Just dismiss the dialog. After reprogramming the arrow keys I managed to use keyboard input in Codea on the iPad.

I thought I'd bricked it for a while because I couldn't get the upload to work to reset the firmware to the unmodified git version. For some reason you don't just briefly touch the reset to ground, you have to hold it until you see Arduino software 'Uploading'.
« Last Edit: December 06, 2013, 10:12:06 PM by Arvicola »

emmaw

  • MaKey MaKer
  • Posts: 5
    • View Profile
Re: how to connect your MaKey MaKey to an iPad
« Reply #3 on: October 23, 2014, 04:10:13 PM »
Hi, sorry for the stupid question, but I'm kind of baffled by this - not by editing the MaKey MaKey, that seems to have gone okay, but eric's Javascript doesn't trigger either a colour change or a sound sample for me - I checked Firebug and I'm getting the error 'TypeError: myAudioContext is undefined' at line 67 which I assume has something to do with it. Have I misunderstood? Is there a missing component to this?

EDITED TO ADD: I didn't realise this only works in Safari. I'm attempting to get it working in other browsers as well!
« Last Edit: October 23, 2014, 06:06:39 PM by emmaw »

jvouillon

  • MaKey MaKer
  • Posts: 3
    • View Profile
Re: how to connect your MaKey MaKey to an iPad
« Reply #4 on: January 26, 2016, 10:00:35 AM »
just an update. The URL for the Defitech.ch article is, now:
http://www.defitech.ch/handigeek.php?item=172