Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

reading touching screen

Status
Not open for further replies.

kirtan

Junior Member level 2
Junior Member level 2
Joined
Mar 11, 2011
Messages
20
Helped
1
Reputation
2
Reaction score
1
Trophy points
1,283
Visit site
Activity points
1,515
I am using 4 wire resistive type touch screen interfaced with microcontroller (ATMega).

I have designed the program according to the required algorithm, y+ 5V y- 0v, read x- and then x+ 5V, x- 0V and read y-.

When i ready only x value it gives me correct answer, when i read the y value it also gives me correct value but when i try to read x and y in sequence then i get correct value of y but not of x. x almost remains constant.

Part of the code is shown below
/* par of main function*///////////////
while(1)
{
x_value = read_x();
lcd_command(0x82);
disp_lcd(x_value);
delay_ms(20);

y_value = read_y();
lcd_command(0xC2);
disp_lcd(y_value);

delay_ms(200);
}
/*................................................*/////////

part of routines
#define x_p PORTA0
#define y_p PORTA1
#define x_m PORTA2
#define y_m PORTA3

unsigned int read_x(void)
{ unsigned int ADC_value;

setbit(DDRA,y_p); //set as output pins
setbit(DDRA, y_m);

setbit(PORTA,y_p); //set as 1 +5V
clearbit(PORTA,y_m); //set as 0 0V

ADC_value = read_ADC(x_m);

return ADC_value;
}

unsigned int read_y(void)
{ unsigned int ADC_value;

setbit(DDRA,x_p); //set as output pins
setbit(DDRA, x_m);

setbit(PORTA,x_p); //set as 1 +5V
clearbit(PORTA,x_m); //set as 0 0V

ADC_value = read_ADC(y_m);

return ADC_value;
}
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top