Loading...

You have no items in your shopping cart.

 
 
 
×

Registration

Profile Informations

Login Datas

or login

First name is required!
Last name is required!
First name is not valid!
Last name is not valid!
This is not an email address!
Email address is required!
This email is already registered!
Password is required!
Enter a valid password!
Please enter 6 or more characters!
Please enter 16 or less characters!
Passwords are not same!
Terms and Conditions are required!
Email or Password is wrong!
Captcha is required!
Captcha is wrong!

ITDB02 Touch Screen Handwrite Demo

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.7 KiB, 1,109 hits)