NintendoDS Touch Screen to LCD

Tonight’s project was not very hard to do, but I wanted to get the NintendoDS to send output to the LCD.  I plugged in the NintendoDS screen and the LCD screen the way I’ve done before in previous tutorials.  If you want to know how to wire the LCD you can go here (http://arduino.cc/en/uploads/Tutorial/LCD_bb.png).  Plugging in the NintendoDS to the A0-A3 pins gives me all of the contacts that I need to wire the entire board together.  The hardest part… the code — ok it wasn’t that hard.  If you look at the code below it’s the same as the LCD code merged with the NintendoDS code.  I basically, added a loop that I call the nintendoLoop() (the same as I had done with the Ping sensor) and returned a value (in this case the concatenation of the String) then I pass that value to the lcdLoop (which used to take the integer of the ping distance) so that the display will show: “x:  #### – y: ####”

That’s it.  Pretty easy stuff.  I should probably go through some of this code and do a walk through of the different portions so that newbies can get a feel for the program.  If you’re interested in something like that, let me know.  I’ll take the extra time to better “document” the process.

// include the library code:
#include

// initialize the library with the numbers of the interface pins
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);

int y1 = A0;
int x2 = A1;
int y2 = A2;
int x1 = A3;

void setup() {
// set up the LCD's number of columns and rows:
lcd.begin(16,2);

// initialize serial communication:
Serial.begin(9600);
}

void loop() {
String nintendoLoo = nintendoLoop();
lcdLoop(nintendoLoo);
}

int readX(){
pinMode(y1, INPUT);
pinMode(x2, OUTPUT);
pinMode(y2, INPUT);
pinMode(x1, OUTPUT);

digitalWrite(x2, LOW);
digitalWrite(x1, HIGH);

delay(5); //pause to allow lines to power up

return analogRead(y1);
}

int readY(){

pinMode(y1, OUTPUT);
pinMode(x2, INPUT);
pinMode(y2, OUTPUT);
pinMode(x1, INPUT);

digitalWrite(y1, LOW);
digitalWrite(y2, HIGH);

delay(5); //pause to allow lines to power up

return analogRead(x2);
}

String nintendoLoop() {
int x = readX();
int y = readY();

String returnValue = "";

if(x < 1000 & y < 1000){
returnValue += "x: ";
returnValue += x-100;
returnValue += " - y: ";
returnValue += y- 130;
}

delay(100); //just to slow this down so it is earier to read in the terminal - Remove if wanted

return returnValue;
}

void lcdLoop(String inches) {
// set the cursor to (0,0):
lcd.setCursor(0, 0);
lcd.clear();

// String output = "";
//output += inches;
// output += " inches";
lcd.print(inches);
}

Here is the touch screen in my hand with no value on the LCD as there is no pressure on the Nintendo DS touch screen.

Here you can see that I am pressing on the screen and a value is displaying on the LCD

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.

%d bloggers like this: