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.


Yes. The upper screen does not have the touch screen overlay which I am using for my project but the screens themselves are exactly the same. As I mentioned, the touch screen part can be bought from sparkfun for under $10.


This looks great. I just ordered this nds touch screen last week.

Should work just like the original you have.. Haven't received it yet though. But shure is interesting.



Yeah for anyone buying a touch screen to use for this kind of project, I would also recommend buying a breakout board for it. I cut the ribbon cable (very carefully) between each contact and soldered and heat-shrinked each one but it's not ideal...



For the price of the replacement DS touch screens, I would highly recommend using them on projects because they are pretty good and transparent which provides endless other uses...

Mike Mc

Potentiometrs would have been cheaper ;) But not as cool.

Is it possible to connect the TFT screens to the Arduino? has anyone done that?


Yes potentiometers would not have been as cool...

Anyway I used the DS touch screen because I had one lying around... I only did the project to find it a use,,,

As far as I know, the DS LCD screens themselves have not been connected to the arduino but it should be possible with another board including ram and another IC like they have on the arduino touch shields... You would probably have to make it yourself though and unfortunately I do not have that much expertise...

Btw, if you want to comment on any other projects I could do or take a look at the pile of stuff I have then please look at:



Mike Mc


Jun 11, 2009, 10:07 am Last Edit: Jun 11, 2009, 10:38 am by mowcius Reason: 1
I've just recently been altering some code to make it a bit better (not finished yet) so I will post one in a day or so...

I am going to alter this to use with the BlinkM MaxM when I get mine in a week or so, maybe I will wait till then for a video...



Hello - This is very cool. Is there a way to get an smaller size?

I'm currently using 1 potentiometer for a project but I would like add the "cool factor" and replace the potentiometer with an small touchscreen (2x5cm inch aprox) and some square leds behind to show the position?

The DS screen would be big for what I need so is there any other thing I can use and not necessarily a touchscreen per say?


Go Up

Quick Reply

With Quick-Reply you can write a post when viewing a topic without loading a new page. You can still use bulletin board code and smileys as you would in a normal post.

Warning: this topic has not been posted in for at least 120 days.
Unless you're sure you want to reply, please consider starting a new topic.

Note: this post will not display until it's been approved by a moderator.

shortcuts: alt+s submit/post or alt+p preview