Turning the Tunisuino into a Makey-Makey

A Makey-Makey is a device that allows you to turn ordinary objects into touch switches. You can play piano with bananas or play Mario with a clay joystick or turn a hand drawn sketch into a touch sensitive keyboard. You just need to touch an object and set your computer reaction.

The principle behind this funny behavior is very simple. It all comes down to a voltage divider, two resistors in serial, one is tied to 5V and the other to 0V.

We have two special cases :

  1. When Rup is very large with respect to Rdown, the voltage at the middle is nearly 0V
  2. When Rup is very tiny with respect to Rdown, the voltage at the middle is nearly 5V

The human body resistance is usually between 1KΩ and 100KΩ depending on several factors. The used objects are usually poor conductors in the range of few kilo ohms. These two resistances together would give a maximum resistance of let's say 150KΩ.

So if we take a resistor of 10MegaΩ as Rup :

  1. When someone touches the object we get 150KΩ <<< 10MegaΩ so the board reads '0'
  2. Otherwise we have 10MegaΩ <<< Air Resistance (Infinity) and the board reads '1' 

We have just made a touch switch !

Now let's move to the software. The Tunisuino provides a very easy way to emulate a keyboard. For instance, to emulate someone who presses the 'A' key every one second, we only have to write the following code : 

void setup() {
  Keyboard.begin();
}

void loop() { 
    Keyboard.write('A');
    delay(1000);
}

To play Mario with a banana joystick, you can wire 4 apples and 2 bananas to the Tunisuino with 10MegaΩ pull-ups :

Then load the following code in which we just keep reading the 6 inputs and writing the appropriate key value :

void setup() {
    pinMode(0, INPUT);
    pinMode(1, INPUT);
    pinMode(2, INPUT);
    pinMode(3, INPUT);
    pinMode(4, INPUT);
    pinMode(5, INPUT);
    Keyboard.begin();
}

void loop() {
    int up = digitalRead(0);
    int down = digitalRead(1);
    int left = digitalRead(2);
    int right = digitalRead(3);
    int jump = digitalRead(4);
    int fire = digitalRead(5);
    
    if (up == 0) {
        Keyboard.write(KEY_UP_ARROW);
    }
    if (down == 0) {
        Keyboard.write(KEY_DOWN_ARROW);
    }
    if (left == 0) {
        Keyboard.write(KEY_LEFT_ARROW);
    }
    if (right == 0) {
        Keyboard.write(KEY_RIGHT_ARROW);
    }
    if (jump == 0) {
        Keyboard.write(' ');
    }
    if (fire == 0) {
        Keyboard.write(KEY_RIGHT_SHIFT);
    }
    
    delay(100);
}

Note that this system only works when the computer and the person are grounded. If you are wearing insulated shoes for instance, you could try touching the wall with the other hand or wiring it to 0V.

0 comments

Login to post a comment