/******************************************************************************* Nintendo DS touchscreen module test program It reads the touchscreen via the analog I/O and broadcasts the reading over the serial connection. If the screen is touched, an LED will light. Hardware: Nintendo DS touchscreen module setup as follows: Analog pins | | Y X | | 5v | | GND \ | | / +---------+ | I I I I | <---Nintendo DS touchscreen ribbon cable (connector side up) | I I I I | | | | | | | *******************************************************************************/ int X_PIN = 6; //This analog pin reads the X direction int Y_PIN = 7; //This analog pin reads the Y direction int LEDpin = 15; //A PWM port for our LED int currentX = 0; int currentY = 0; void setup(){ Serial.begin(9600); //Set serial to 9600 bps } void loop(){ currentX = (1023-analogRead(X_PIN)); //This flips the X direction currentY = analogRead(Y_PIN); Serial.print("X = "); Serial.print(currentX); Serial.print(" Y = "); Serial.println(currentY); //Let's make the LED blink when we press the pad... if(currentX > 0 && currentY > 0) //If it's touched... analogWrite(LEDpin, 255); if(currentX < 3 && currentY < 3) //If it's released... analogWrite(LEDpin, 0); }