Trying to get this touchscreen working with my Arduino i come across with this http://hades.mech.northwestern.edu/wiki/index.php/Interfacing_with_a_touchscreen, yah i know is for a PIC, but i tried to get this working in the Arduino, here's the code:
#include <LiquidCrystal.h>
unsigned int xPos;
unsigned int yPos;
void get_xPos_yPos(unsigned int& xPos, unsigned int& yPos);
LiquidCrystal lcd(2, 3, 4, 5, 6, 7, 8);void setup()
{
lcd.clear();
Serial.begin(9600);
//sends the string FT to the EXII 7720SC
Serial.print(0x01,BYTE);
Serial.print(0x46,BYTE);
Serial.print(0x54,BYTE);
Serial.print(0x0D,BYTE);
}void loop()
{
//get the position of the touch and display it on the lcd.
get_xPos_yPos(xPos, yPos);
lcd.clear();
lcd.print("X: " + xPos);
lcd.setCursor(0,1);
lcd.print("Y: " + yPos);
}//this is how you get the x and y coords
void get_xPos_yPos(unsigned int& xPos, unsigned int& yPos)
{
int j;
int i;
int gotD8;
byte touchRX[20];
byte pos[5];
byte high;
byte low;
unsigned int xtot;
unsigned int ytot;
unsigned int temp4;
unsigned int tot8;
high = 0;
low = 0;
xtot = 0;
ytot = 0;
temp4 = 0;
tot8 = 0;
//get 10 bytes from the EXII 7720SC
for (i=1;i<=10;++i)
{
if(Serial.available())
{
touchRX = Serial.read();
- }*
- }*
- //find the 0xD8 byte*
- gotD8 = 0;*
- j = 1;*
- while(gotD8 == 0)*
- {*
- if((touchRX[j] == 0xD8))*
- {*
- gotD8 = 1;*
- }*
- else*
- {*
- j = j+1;*
- }*
- if(j == 9)*
- {*
- gotD8 = 1;*
- }*
- }*
*//once you have the position of the 0xD8 save the rest of the stream in the array of position *- pos[1]=touchRX[j+1];*
- pos[2]=touchRX[j+2];*
- pos[3]=touchRX[j+3];*
- pos[4]=touchRX[j+4];*
//get each of the coords in a 16-bit format
temp4 = pos[2];*
high = temp4;*
low = pos[1];*
xtot = low|(high << 7);*
xPos = xtot;*
temp4 = pos[4];*
high = temp4;*
low = pos[3];*
ytot = low|(high << 7);*
yPos = ytot;*
}
[/quote]
i'm going to try it with the EXII 7720SC later, today. Just wanna know what u think about it. Btw the datasheet for this controller http://multimedia.mmm.com/mws/mediawebserver.dyn?6666660Zjcf6lVs6EVs66SBhjCOrrrrQ-