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...
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 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.
/*
* 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.
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.
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.
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...
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:
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?
It looks like the smallest you can get is 1.8" diagonal made for small phones etc and then you can get varying other sizes going up to about 15" but most places seem to want to sell a couple of thousand so they may be difficult to get hold of.
The DS touch screen is easy to get hold of and relatively cheap and you don't have to buy thousands
Just do a search for a 4 wire resistive touch screen.
How did you go about connecting the DS touchscreen to wires you could use in the breadboard? i have one (well two actually as i assume i will mess up the connection on at least one!) and would love any tips for how you went about it. My current plan is a to cut between the wires using a modelling knife.
Does anyone know of a way to get rid of the plastic overlay thats on the wires then it would be easy to connect wires at the base of the wires.
I just did it carefully with a sharp pair of scissors and then laid 4 wires on the connectons and soldered them up with some heatshrink round it to stop the joint flexing so much... I didn't remove any plastic or anything...
Anternatively, if you like surface mount soldering you can buy the touch screen connector from sparkfun... I presume that it works with both the DS and DS lite touch screens (it looks like it should)
Still no video of this in action? I've added one to my Wish list (2.99 free shipping on eBay, can't beat that!), but I'd love to see how yours looks while functioning :).
Oh, sorry. I dismantled it to use some of the parts as I still only have one arduino! If I remember then I will still try to a get a video done eventually. The LEDs on the picture were not evenly matched so it didn't mix very well and I have not got round to playing with the i2c commands for my blinkm maxm yet...