Go Down

Topic: RGB Colour Mixer with DS touch screen (Read 7 times) previous topic - next topic


This is a simple project and the code is a bit crude for it but it works...


I am going to laser cut a case (when I can use a laser cutter again-in a few months) for it and this will also separate the screen and distinguish the sliders with channels. I am probably going to have some sort of translucent/frosted dome with one single RGB LED in it to provide a mood light...

Any ideas welcome,



Hi, is there any chance to get some schemes or some source? On your website, there is no more info than just pictures. Good idea, but isn't DS touch screen too expensive for that? BTW very interesting project.


Well my website unfortunately is not online yet.... I am just using flikr for the time being. The DS touch screen is only about £7 or $10 so not going to make you bankrupt. I got mine off an old DS anyway.

Anyway, here is the code. It is very simple and very crude :P The numbers are so strange because it is a third of the values I got from my touch screen. The values for the LEDs are also a bit strange (but do work for the LEDs I have) but if someone can improve upon them then I would be very grateful. I am going to have another look at this project in a week or so when I am not so busy and I then might get round to laser cutting my case for it.

Code: [Select]


* ds_touch_screen_mood_light.PDE - Arduino sketch - approx 1552 bytes

* Read from a touch panel the touch position

* Then light up RGB LED using 3 split screen on Y and fading on X


* Hardware used:

* Resistive touch panel, 4 wire (DS touch screen)

* Arduino board, LEDs


* May 25th 2009

* by Robin Whitfield


*     *********

* Original touch screen code:

* April 5th 2009

* by Marco Nicolato

*     *********


// vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv

// Touch panel wiring


//When looking at DS screen with connector bottom left they are in order going down as follows:






// Digital connections (used to drive power)

#define Lo 2 // LEFT to digital output 2

#define Bo 3 // BOTTOM to digital output 3

#define Ro 4 // RIGHT to digital output 4

#define To 5 // TOP to Digital output 5

// Analog connections (used to read the touch position)

#define Ti 3 // TOP also to analog input 3

#define Ri 4 // RIGHT also to analog input 4

//define the LED pins:

#define LEDR 9  //set LEDR as pin 8

#define LEDG 10  //set LEDG as pin 9

#define LEDB 11  //set LEDB as pin 10

// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

// vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv

// set initial touched position

int touchX = 0;

int touchY = 0;

// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

void setup()


 pinMode(LEDR, OUTPUT);  //set all LED pins as output pins

 pinMode(LEDG, OUTPUT);  //"

 pinMode(LEDB, OUTPUT);  //"


void loop()


 if (touched())  //if the screen is touched then...


 if(touchY < 388)  //if x touch position is less then 1/3 of screen then:

   analogWrite(LEDB, touchX/4 -18);  //write brightness to blue LED

 else  //if not, then:

 if(touchY > 623)  //if x touch position is more than 1/3 of screen then:

   analogWrite(LEDR, touchX/4 -18);  //write brightness to red LED

 else  //if not, then:

   analogWrite(LEDG, touchX/4 -18);  //write brightness to green led



// return TRUE if touched, and set coordinates to touchX and touchY

boolean touched()


 boolean touch = false;

 // Horizontal routine - set L to gnd and R to Vcc

 // set L = ground

 pinMode(Lo, OUTPUT);

 digitalWrite(Lo, LOW);

 // set R = Vcc

 pinMode(Ro, OUTPUT);

 digitalWrite(Ro, HIGH);

 // T e B high impedance (input mode)

 pinMode(To, INPUT);

 pinMode(Bo, INPUT);

 // wait a bit, then read from Top


 touchX = analogRead(Ti);

 // Vertical routine - set B to gnd and T to Vcc

 // Set B = gnd

 pinMode(Bo, OUTPUT);

 digitalWrite(Bo, LOW);

 // set T = Vcc

 pinMode(To, OUTPUT);

 digitalWrite(To, HIGH);

 // R e L high impedance (input mode)

 pinMode(Ro, INPUT);

 pinMode(Lo, INPUT);

 // wait a bit, then read from Right


 touchY = analogRead(Ri);

 // Only read touch if coords are below 1000 and above 0 (stops errors with certain screens)

 if(touchX < 1000 and touchX > 0 and touchY < 1000 and touchY > 0)

   touch = true;


   return touch;


Yeah, crude I know. Any improvements would be welcomed and any ideas as how to advance the project would be great.



With the DS touch screen only costing about a tenner, it could be used for a lot more than it is currently. I am  now doing a project with laser cutting a front to separate it into 2 sliders and 4 buttons for another project I am doing.



Is there any difference between upper and lower DS screen? I didn't know that Nintendo has touch screen, and the price is really interesting.

Go Up