C CODE TO DISPLAY A NUMBER STORED IN A VARIABLE USING AT89c51/AT89s52

Status
Not open for further replies.

Wesley90

Junior Member level 1
Joined
Jan 29, 2013
Messages
15
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,410
Hi,
I've basically designed a keypad interface using 8051 and 16*2 LCD display where a time is set n the countdown begins(say 150secs and downwards)!!
I've used a "for" loop to give one second delay..Now i need to display the decremented number after every second..Eg:150...149 and so on till 0..I want to know how to decrement a number stored in the variable n den display the contents of the variable..
Eg: val=150;
val=--val;
Delay of 1 second;
HOW TO DISPLAY THE CURRENT VALUE of val????

Plz do help!!
 


Code C - [expand]
1
2
3
4
5
6
7
val = --val
strVal[0] = val/100 + 0x30;
strVal[1] = (val/10)%10 + 0x30;
strVal[2] = (val/1)%10 + 0x30;
strVal[3] = '\0';
 
lcd_string(strVal);

 

Status
Not open for further replies.
Cookies are required to use this site. You must accept them to continue using the site. Learn more…