arduino with touch screen to achieve handwrite
use the Arduino to control the ITDB02-2.4 display , and used the touch screen to achieve handwrite function.
The LCD connection is the same as that in “ITDB02-2.4 8Bit Mode Demo“, and the touch screen connection is :
DCLK to D14(A0) pin of Arduino
CS to D15(A1) pin of Arduino
DIN to D16(A2) pin of Arduino
DOUT to D18(A4) pin of Arduino
IRQ to D19(A5) pin of Arduino
The display code is the same as we have released , now we just give a brief introduction of SPI and touch IC control.
SPI Start:
void spistar()
{
digitalWrite(CS,HIGH);
digitalWrite(DCLK,HIGH);
digitalWrite(DIN,HIGH);
digitalWrite(DCLK,HIGH);
}
SPI Write Data function:
void WriteCharTo7843(unsigned char num)
{
unsigned char count=0;
unsigned char temp;
unsigned nop;
temp=num;
digitalWrite(DCLK,LOW);
for(count=0;count[HTML_REMOVED]8;count++)
{
if(temp[HTML_REMOVED]0x80)
digitalWrite(DIN,HIGH);
else
digitalWrite(DIN,LOW);
temp=temp<<1;
digitalWrite(DCLK,LOW);
nop++;
nop++;
digitalWrite(DCLK,HIGH);
nop++;
nop++;
} } SPI Read Data function:
unsigned int ReadFromCharFrom7843()
{
unsigned nop;
unsigned char count=0;
unsigned int Num=0;
for(count=0;count[HTML_REMOVED]12;count++)
{
Num[HTML_REMOVED][HTML_REMOVED]=1;
digitalWrite(DCLK,HIGH);
nop++;
digitalWrite(DCLK,LOW);
nop++;
if(digitalRead(DOUT)) Num++;
}
return(Num);
}
Get coordinates:
void AD7843(void)
{
digitalWrite(CS,LOW);
WriteCharTo7843(0x90);
digitalWrite(DCLK,HIGH);
digitalWrite(DCLK,LOW);
TP_Y=ReadFromCharFrom7843();
WriteCharTo7843(0xD0);
digitalWrite(DCLK,HIGH);
digitalWrite(DCLK,LOW);
TP_X=ReadFromCharFrom7843();
digitalWrite(CS,HIGH);
}
Download the code into Arduino , and you can see the handwrite effects as the previous image shown :
Note : ITDB02 the touch and LCD is 3V3 , so if you want to use the Arduino 5V pin to connect it , reduction voltage and limiting current part is necessary .
You can find more information and whole project here: http://iteadstudio.com/application-note/itdb02-touch-screen-handwrite-demo