Today we show a demo that 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<8;count++) { if(temp&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<12;count++) { Num<<=1; digitalWrite(DCLK,HIGH);//DCLK=1; _nop_();_nop_();_nop_(); nop++; digitalWrite(DCLK,LOW);//DCLK=0; _nop_();_nop_();_nop_(); 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 : 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 download the demo project here:
ITDB02 Touch with Arduino (2.2 KiB, 860 hits)
You may also be interested in these posts:
In you library you are using some hardcoded values:
lx=240-((TP_X-220)/16);
ly=320-((TP_Y-400)/11);
Can you explain where 220 and 16 comes from in calculation of x?
Same for 400 and 11 in y calculation.
Thank you
It looks great, but on my arduino with my ITDB02-Shield it doesn´t work
The shield is configured: all jumpers on “T&SD” and the switch is also on “Touch”-Position, but wherever I point on the display, theres nothing on the Display… No Dot and no coordinates on the left bottom!
Can you help me?
Thanks a lot
@ Jonathan
You should make sure what Specific LCD module you are using with the shield, if the your LCD module is purchased from us, you can send the mail to support@iteadstudio.com for more help. If your LCD is not buy from us, you need to get the help with your supplier.
@ITead
I´ve bought it not directly from iteadstudio.com, but i´ve bought it from “eBay” and it cames in a blue bag, which stood on it:
ITead Studio
* Make Innovation easier
*Here was the logo…