Pages: [1] 2 3   Go Down
Author Topic: RGB Colour Mixer with DS touch screen  (Read 7609 times)
0 Members and 1 Guest are viewing this topic.
North Yorkshire, UK
Offline Offline
Faraday Member
**
Karma: 104
Posts: 5531
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

http://www.flickr.com/photos/mowcius/3572919432/

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,

Mowcius
Logged

Poland - Wroclaw
Offline Offline
Newbie
*
Karma: 0
Posts: 7
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

North Yorkshire, UK
Offline Offline
Faraday Member
**
Karma: 104
Posts: 5531
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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 smiley-razz 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:
/*

 * 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:

//TOP

//LEFT

//BOTTOM

//RIGHT

//

// 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

  delay(10);

  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

  delay(10);

  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.

Mowcius
Logged

North Yorkshire, UK
Offline Offline
Faraday Member
**
Karma: 104
Posts: 5531
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.

Mowcius
Logged

Poland - Wroclaw
Offline Offline
Newbie
*
Karma: 0
Posts: 7
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

North Yorkshire, UK
Offline Offline
Faraday Member
**
Karma: 104
Posts: 5531
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

0
Offline Offline
Newbie
*
Karma: 0
Posts: 2
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

This looks great. I just ordered this nds touch screen last week.
dealextreme.com/details.dx/sku.3245

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

0
Offline Offline
Newbie
*
Karma: 0
Posts: 3
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

cool and simple idea!
Logged

North Yorkshire, UK
Offline Offline
Faraday Member
**
Karma: 104
Posts: 5531
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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...

Mowcius
Logged

North Yorkshire, UK
Offline Offline
Faraday Member
**
Karma: 104
Posts: 5531
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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...
Logged

London, England
Offline Offline
Edison Member
*
Karma: 4
Posts: 1026
Go! Go! Arduinoooo !!!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Potentiometrs would have been cheaper smiley-wink But not as cool.

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

North Yorkshire, UK
Offline Offline
Faraday Member
**
Karma: 104
Posts: 5531
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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:

 http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1243337100

Mowcius
Logged

London, England
Offline Offline
Edison Member
*
Karma: 4
Posts: 1026
Go! Go! Arduinoooo !!!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Any videos of this in action yet?
Logged

North Yorkshire, UK
Offline Offline
Faraday Member
**
Karma: 104
Posts: 5531
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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...

Mowcius
« Last Edit: June 11, 2009, 03:38:30 am by mowcius » Logged

0
Offline Offline
Newbie
*
Karma: 0
Posts: 7
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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?

Thanks
Logged

Pages: [1] 2 3   Go Up
Jump to: