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.

[SOLVED] How to increment two no. in lcd?

Status
Not open for further replies.

ps_arunkumar

Member level 1
Joined
Nov 24, 2011
Messages
36
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,286
Activity points
1,545
How to display two no. in lcd?

Hi all,
I have connected two switches to AT89c52. I am trying to display individual no. so that when a switch is pressed, it will be displayed in lcd. C code which i have written using Keil compiler works but one switch is dependent on other i.e.,I have to press switch 1 and it will display a no. and if i continue to press switch 1 the no. wont increment. After pressing the switch2, i can increment the switch1 no. hen i should press switch2 again to increment switch 1.

I am some logic and I have tried to find but i couldn't. Please help me.
 

Attachments

  • switch.zip
    1.6 KB · Views: 78
Last edited:

What could be understood from the post is that:
AT89c52 based circuit has two switches at one port (Port 1, bit 0 and 1) and LCD display is also attached and working.
It is expected that :
On pressing (tapping) one switch first number displayed (on LCD) should increment.
On pressing (tapping) the other switch second number displayed (on LCD) should increment.
and what is happening is that
if first switch is used once, it is not effective till one uses the other switch (which is not what is needed)
Is this correct interpretation of the issue, this will help arriving at a suggestion.
Raoof
 

To be able to use a pin as input it has to be written 1 ( or HIGH).
also the way the polling of the switches is implemented seems fussy and may be reivised.
Raoof
 

I am not sure how to revised the polling of switches. I have tried with switch case and while loop but it doesn't worked. Can you please say how should i write a code for proper polling.
 

I revised the polling of switch and it worked as i expected.

void main()
{
unsigned char switch_presses = 0, switch_presses1 = 0;
switch_pin=0;
switch_pin1=0;
PowerOn();
while(1)
{
if(switch_pin==1)
{
while(switch(switch_pin==1);
switch_presses++;
sendno2lcd(switch_presses);
}

if(switch_pin1==1)
{
while(switch(switch_pin1==1);
switch_presses1++;
sendno2lcd(switch_presses1);
}
}
}

thanks for the help.
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top