📄 0_99.c
字号:
#include<16f877.h>
#fuses XT,NOLVP,NOWDT,PUT
#use delay (clock=4000000) // defind crystal = 4MHz
#use rs232(baud=9600, xmit=PIN_C6, rcv=PIN_C7)
#byte port_d=8
#byte port_a=5
byte CONST LED_MAP[10]={0xC0,0xF9,0xA4,0xB0,0x99,0x92,0x82,0xF8,0X80,0x90};
increment_sw();
int n;
//===========================================
// this function use to display number 00=999
// input : n = number to display
//===========================================
void display_number(long int n)
{
output_d(LED_MAP[n%10]) ;//unit position ;n=0 to 9
output_low(PIN_A0);
delay_ms(2);
output_high(PIN_A0);
/*
output_d(LED_MAP[n/10%10]) ;//tens position
output_low(PIN_A1);
delay_ms(2);
output_high(PIN_A1);
output_d(LED_MAP[n/100%10]);//hundards position
output_low(PIN_A2);
delay_ms(2);
output_high(PIN_A2);*/
}
//============================================
// main program
//============================================
void main()
{
long int count=1;
if(!input(pin_b0))
{
count++;
if(count==10)
count=0;
output_d(LED_MAP[n%10]);
increment_sw();
}
while(TRUE)
{
int i;
for (i=0;i<=200;i++)
display_number(count); // dispay 200 times
count=(count==9) ? 1: count+1; //count+1=++count
}
}
increment_sw(){
int a;
for(a=0;a<20;a++){
for(i=0;i<200;i++)
{
delay_us(10);
}
}
display_nuber(count);
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -