Capacitive Touch controller Help!

Hi Everyone,

I was hoping to get some help form the community because i have been at this for around 2 weeks and its so frustrating haha.

Explaination:
So my project idea is to make a video game controller that is painted on to a piece of card an use it as a nes controller via emulators.
I have the first prototype painted and have got it working with the capacitive touch function.
I know this because in the serial monitor it will tell me what pad i’m touching via different numbers(Pins). (E.G 1 = up, 2 = Left, and so on.’)

The equipment i have is,
Ardiuno uno, and adafruit MPR121.

I think the main problem i am having is getting the input to work within games.

The code im using at the moment:

#include <Wire.h>
#include <Adafruit_MPR121.h>

Adafruit_MPR121 cap = Adafruit_MPR121();

uint16_t currenttouched = 0;
const uint16_t wait = 100;
int var =0;

void setup()
{
// put your setup code here, to run once:

Serial.begin(9600);

if (!cap.begin(0x5A))
{
Serial.println(“MPR121 not found, check wiring?”);
while (1);
}

}

void loop()
{
// put your main code here, to run repeatedly:
currenttouched = cap.touched();
var =0;
//-------------------------SW1-----------------------------
if(currenttouched & _BV(0)) // = up
{
var = 1;
Serial.print(var);
Serial.print(".");
delay(wait);
}

//-----------------------SW2--------------------------------
if( currenttouched & _BV(1)) // = down
{
var = 2;
Serial.print(var);
Serial.print(".");
delay(wait);
}

//----------------------------SW3---------------------------
if( currenttouched & _BV(2)) // = right
{
var = 3;
Serial.print(var);
Serial.print(".");
delay(wait);
}

//---------------------------SW4------------------------------
if( currenttouched & _BV(3)) // = left
{
var = 4;
Serial.print(var);
Serial.print(".");
delay(wait);
}
//--------------------------SW5-----------------------------
if(currenttouched & _BV(4)) // = space
{
var = 5;
Serial.print(var);
Serial.print(".");
delay(wait);
}
//-------------------------SW6--------------------------
if(currenttouched & _BV(6)) // = shift
{
var = 6;
Serial.print(var);
Serial.print(".");
delay(wait);
}
// ----------------------SW7---------------------------
if(currenttouched & _BV(7)) // = enter
{
var = 7;
Serial.print(var);
Serial.print(".");
delay(wait);
}
else
{
Serial.print(var);
Serial.print(".");
}

}


Im Still a beginner to be honest, and it is such a learning curve.

Thank you to everyone in advance,
If you need anymore information please let me know!

Thanks!
Luke

Start by reading Read this before posting a programming question and follow the instructions for posting code to make it easy to provide help

Basically, that is not an Arduino based problem. You have already managed to adjust the serial output of your Arduino in a way that should be functional for your project (I did not make any similar project yet).

What you have to do now is make your emulator accept the incoming serial commands. If we don’t know which emulator you are using and how your exact setup looks like we can not really help you.

Hi LowArt,

Awesome, thank you.
Sorry i didn’t make it clear in my post,
The emulator I am using is nestopia, and the game i’m trying to run is super mario bros.
I have attached some screenshots of what i think was important settings on the emulator.

I wouldn’t really know where to begin to make the emulator accept the incoming serial commands,
which makes this a bit difficult.

Im going to do some research, if i find out anything i will post here to let everyone know.

Any suggestions is very appreciated!

Thanks!

Luke. :slight_smile:

I'm sure you can find more information about this Nestopia thing on a Nestopia forum. It doesn't seem to have anything to do with the Arduino as such.