单片机型号:PIC16LF1559,定时250ms,LED口为RC5,代码如下:
#include<pic.h>
#include <xc.h>
#pragma config FOSC = INTOSC
#pragma config WDTE = OFF
#define uint unsigned int
void main()
{
uint num;
TRISC = 0xdf;
OPTION_REG = 0x08;
RC5 = 0;
while(1)
{
if(TMR0IF == 1)
{
TMR0IF =0;
num++;
if(num == 976)
{
RC5 =~RC5;
num =0;
}
}
}
}
|