12hours CLOCK program...

Status
Not open for further replies.

sonic05

Member level 1
Joined
Mar 14, 2010
Messages
32
Helped
1
Reputation
2
Reaction score
1
Trophy points
1,288
Location
Manila
Activity points
1,580
12hours CLOCK program...
THE ic that i used is 16f877a...

anybody can help me for this program,..


#include<16f877.h>
#fuses XT,NOLVP,NOWDT,PUT
#use delay (clock=1M)
#byte port_d=8
#byte port_a=5
#byte port_c=8
byte CONST LED_MAP[10]={0x3F,0x06,0x5b,0x4F,0x66,0x6D,0x7D,0x07,0X7F,0x6 F};

void display_number(int32 j)
{

output_c(LED_MAP[j/600%10]) ;
output_low(PIN_A4);
delay_ms(2);
output_high(PIN_A4);

output_c(LED_MAP[j/60%10]) ;
output_low(PIN_A3);
delay_ms(2);
output_high(PIN_A3);

output_c(LED_MAP[j/10%6]) ;
output_low(PIN_A2);
delay_ms(2);
output_high(PIN_A2);

output_c(LED_MAP[j%10]);
output_low(PIN_A1);
delay_ms(2);
output_high(PIN_A1);

}

void main()
{
int32 m,count=0;

while(TRUE)
{
for (m=0;m<=10;m++)
display_number(count);
count=(count==3600)? 0:count+1;
}
}


i want to have a program like a 12hours clock [1][2]:[0][0] but idont know if it is possible to used this program because this program is for [6][0]:[0][0] stopwatch...

(LED_MAP[j%10]); and im also confuse in this part..
 

LED_MAP[] is an array of constants defined at the beginning of the code.

The operator % is the modulo operator, so j%10 = mod(j,10) which can be seen as j%10= j-10*floor(j/10).
i.e j=23, j%10=2

The values stored at LED_MAP are the 7-segment display activation values to show 0-9 digits.

To modify the program to 12hours clock, you should to check the counters and modulo operations of each digit.
 

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