ac7-2.c

来自「AVR学习资料」· C语言 代码 · 共 39 行

C
39
字号
#include<iom16v.h>			
#define uchar unsigned char	
#define uint unsigned int
uchar const SEG7[10]={0x3f,0x06,0x5b,0x4f,0x66,	
                0x6d,0x7d,0x07,0x7f,0x6f};
uchar const ACT[2]={0xfe,0xfd};				
//=============================
void delay_ms(uint k)			
{
    uint i,j;
    for(i=0;i<k;i++)
    {
       for(j=0;j<570;j++);
    }
}
//=============================
void main(void)	
{				
uchar i,counter;	
DDRA=0xff;			
DDRC=0xff;		
PORTA=0x00;		
PORTC=0xff;		
   while(1)		
   {			
   		   for(i=0;i<100;i++)	
   		   {					
		   PORTA=SEG7[counter%10];	
   		   PORTC=ACT[0];			
   		   delay_ms(1);				
   		   PORTA=SEG7[counter/10];	
   		   PORTC=ACT[1];			
   		   delay_ms(1);			
		   }					
		   counter++;		
		   if(counter>99)counter=0;	
   }						
}							

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?