Author Topic: Don't want to be grounded? Don't be, and use this capacitive sensing hack!  (Read 41915 times)

Arvid

  • MaKey MaKer
  • Posts: 5
    • View Profile
Hey Guys,

While working in a masterclass hosted by Eric Rosenbaum and Micheal Michael Smith-Welch, using the Makey Makey to create crazy musical instruments, some of the projects were finding the need for ground to be a bit of a nuisance. Someone came with the idea that capacitive sensing might be a nice improvement. I really liked the idea and went to work on it.

There are several ways to use capacitive sensing on an Arduino. Some examples found on the internet needed multiple pins or specific hardware. I finally found an Instructable using a pullup resistor and a single pin, actually quite similar to the pullup present on the Makey Makey. After some tries of getting the code onto the device, it seemed to work!

Having a proof of principle, I went on to write code, with a aim to make the Capacitive Makey Makey just as useful as the orginal. This involved some iterations of debouncing code. But once it was done, it really did seem to work as well as hoped.

We applied the modified firmware in the coat and conductive-wire-harp shown in this video:
Music as Material workshop highlights


Instructable using pullups: http://www.instructables.com/id/Turn-a-pencil-drawing-into-a-capacitive-sensor-for/
Arduino example: [url]http://www.arduino.cc/playground/Code/CapacitiveSensor]http://www.arduino.cc/playground/Code/CapacitiveSensor] [url]http://www.arduino.cc/playground/Code/CapacitiveSensor[/url]

Anyways, here is the code:
Capacitive Makey Makey code: http://pastebin.com/xmi8wL9U
To use this, paste and upload the code into your Makey Makey, following the instructions on this site http://www.sparkfun.com/tutorials/378
Limitations on this version:
-Does not yet work on all the inputs
-Not all bindings are correct (sending z-n instead of arrow keys)
-Does not use the Setting.h file
-Debounce and capacitive sensing is not optimized for this application
-Uses keyboard.print instead of pressed/release, this makes the feel of this hack a bit different than the original MM
-Code is a bit clunky, it could be shortened by using an array, a single readpin function and magic
-This thing could be improved to make a pressure sensitive MakeyMakey!
-The capacitive sensing did not seem to work on larger structures, where the original MM did work.

(a variation of this code has even worked with the upcoming bluetooth shield!)

Please feel free to use this code in any way possible, though it would be awesome to see some results back here!

Greeting.
Arvid
« Last Edit: October 25, 2012, 07:53:54 PM by Arvid »

Arvid

  • MaKey MaKer
  • Posts: 5
    • View Profile
Re: Don't want to be grounded? Don't be, and use this capacitive sensing hack!
« Reply #1 on: December 19, 2012, 02:30:57 PM »
I finally dug up a video of something we did with this: a musical fur



edit: to clarify, the girl in the video sewed a few conductive threads through the jacket, it should make music when stroked. At first the person interacting with this, would've needed to hold a ground wire, before it worked. Which was quite inconvenient. So by using the capacitive hack, it would work anyways.
« Last Edit: December 20, 2012, 11:42:56 AM by Arvid »

avandermost

  • MaKey MaKer
  • Posts: 4
    • View Profile
Re: Don't want to be grounded? Don't be, and use this capacitive sensing hack!
« Reply #2 on: December 22, 2012, 06:04:45 PM »
amazing! Thanks so much for posting this code. I hope I'll get a chance to try out this modification since it improves the interaction 10 fold!

funkytaco

  • MaKey MaKer
  • Posts: 15
    • View Profile
Re: Don't want to be grounded? Don't be, and use this capacitive sensing hack!
« Reply #3 on: February 10, 2013, 08:57:51 PM »
This is pretty amazing! Thank you!

I can now use the MakeyMakey without holding a ground wire :)

A note to anybody else using this, MakeyMakey's are Arduino Leonardo boards, so select that board in the software you load the sketch into.

Also, it looks like you re-mapped the keys (space was X), so here is an ASCII chart.
http://arduino.cc/en/Reference/ASCIIchart

For example, I wanted the space button to send a space (not X). Space is a non-printable character, so you use Keyboard.write(), not Keyboard.println():

Keyboard.write(32);         // sends ASCII value 32, a space

If you wanted to see what I mean, 'x' is being printed on line 132 of the code above - I just commented out that line and replaced it with the one above (the chart shows 'space' is ASII character #32).


Should this raise any safety concerns, though (not having to hold the ground)?
« Last Edit: February 10, 2013, 09:00:25 PM by funkytaco »

funkytaco

  • MaKey MaKer
  • Posts: 15
    • View Profile
Re: Don't want to be grounded? Don't be, and use this capacitive sensing hack!
« Reply #4 on: February 11, 2013, 12:47:01 PM »
I've run into a problem. It appears the MakeyMakey needs to be unplugged/re-plugged the USB cord after a while.

xceph

  • MaKey MaKer
  • Posts: 1
    • View Profile
Re: Don't want to be grounded? Don't be, and use this capacitive sensing hack!
« Reply #5 on: February 12, 2013, 07:24:46 PM »
I just programmed this on, which worked fine, but the operation didn't seem to work as I had expected.  Infact it didn't seem to work any differently, other than different keys being used.

I had attached two clips to a wire, and was expecting the event to be triggered when I touched the wire (Is this the correct assumption??), instead it only happens when joining, much like the original Makey Makey firmware. 

I did notice that the keys it sends were behaving oddly, for instance in my Text editor, Sublime Text 2, they wouldnt show up as keystokes, just as tabs or somethign similar, in Notepad they worked fine.

This was on Windows 7 64 bit.

funkytaco

  • MaKey MaKer
  • Posts: 15
    • View Profile
Re: Don't want to be grounded? Don't be, and use this capacitive sensing hack!
« Reply #6 on: February 13, 2013, 01:39:27 AM »
I had attached two clips to a wire.
Don't do that, that's going to create odd circuit issues. This is only meant to remove the need to be grounded (i.e. connecting a clip to the "Earth" part of the MakeyMakey). You still need to clip to different objects (I chose thumb tacks for my test).


I still have issues with needing to unplug/replug the MakeyMakey when I use this code, so if somebody who understands this code knows why you need to reset the MakeyMakey, please let us know.

Arvid

  • MaKey MaKer
  • Posts: 5
    • View Profile
Re: Don't want to be grounded? Don't be, and use this capacitive sensing hack!
« Reply #7 on: February 14, 2013, 09:48:51 AM »
Cool to see that people are actually using this :) The code is quite crude and can be optimized quite a bit, though I don't think I'd have time for that soon. :(

I'm not sure on why it could stop operating after a while, though if you'd want a quick reset, you could put a wire from the rst header to the gnd header for a second. (or even better, put a little button in there.)

Xceph, I'm not sure on what you're trying to do, could you make a little video of draw your setup? As for the keys its sending, it should be similar to the original MakeyMakey code, other than that this sends a keyPressed, rather than a keyOn when held and an keyOff when released.

funkytaco

  • MaKey MaKer
  • Posts: 15
    • View Profile
Re: Don't want to be grounded? Don't be, and use this capacitive sensing hack!
« Reply #8 on: February 15, 2013, 05:25:47 PM »
I'm not sure on why it could stop operating after a while, though if you'd want a quick reset, you could put a wire from the rst header to the gnd header for a second. (or even better, put a little button in there.)

Unfortunately, this is for my wedding photo booth, so I won't have time to mess with a hack, but hopefully that helps with someone else!

Once I get a little more knowledgeable I will see if I can figure out why the makey makey usb cord needs to be reseated after a while, but I'm still learning about Arduino's so it may be a while.

miss_n

  • MaKey MaKer
  • Posts: 6
    • View Profile
Re: Don't want to be grounded? Don't be, and use this capacitive sensing hack!
« Reply #9 on: February 26, 2013, 10:16:06 PM »
Any chance you can pastebin the code for controlling the bluetooth module? I'm futzing around with the makeymate code currently. Wondering if you used something different?

Thanks!

Arvid

  • MaKey MaKer
  • Posts: 5
    • View Profile

Ollie

  • MaKey MaKer
  • Posts: 11
    • View Profile
I was playing a coin piano and then realised I wasn't grounded yet it was still working. How is this possible because the other day I had to be grounded?   ???
--------
Ollie
--------

Heavygain

  • MaKey MaKer
  • Posts: 2
    • View Profile
Awesome, appreciate the code. Hopefully someone can smooth it out a little in the near future.

Makilja

  • MaKey MaKer
  • Posts: 2
    • View Profile
Hi everyone,

I am new to the forum, new to Makey Makey as I just got mine yesterday and new to Arduino as I've never owned or programmed one before last night.

I ordered a ESD bracelet but as it hasn't arrived yet, I thought I would give a try to this nice capacitive sensing trick. As it wouldn't work with http://www.freeinvaders.org/ I modified it to map the original keys in a way that it would work.

Here is the code: * makeymakey_capacitive.zip

Then I found out the it wasn't quite behaving like the original firmware and would become unresponsive at times, so I modified the original firmware to include the capacitive sensing trick.

Here is the code: * makey_makey_1_4_1.zip

I found that code to work well except that it is maybe a bit slow, but I don't know how to fix it. Maybe some expert can help out. In any case it allows pressing "keys" continuously!

I found that it is pretty awesome what one can do so quickly with this platform, even as a newcomer!

I will post my projects when I have something  ;)

funkytaco

  • MaKey MaKer
  • Posts: 15
    • View Profile
Makilja, it sounds like you may have fixed the bug I was running into! I'm going to try your code sometime soon when I have time. Thanks!  :D