📄 main.c
字号:
#include <avr/io.h>
//#include "iocan128.h"
#define TIME 100
#define LED_TIME 40000
#define LED_OK 10000
// Declare your global variables here
void Light(unsigned char a);
void delay_us (unsigned int cntr);
int main(void)
{
// Input/Output Ports initialization
// Port A
DDRA=0x00; //
PORTA=0x00;
// Port B
DDRB=0x00;
PORTB=0x00;
//Port C
PORTC = 0x01;
DDRC = 0x0f;
while(1)
{
PORTC=1;
for(int i=0;i<10;i++)
delay_us(LED_TIME);
PORTC=0;
for(int i=0;i<10;i++)
delay_us(LED_TIME);
}
}
//function stop and set PC0(LED)
void Light(unsigned char a)
{
unsigned char b;
for (b=0;b!=a;b++)
{
PORTC=1;
delay_us(LED_TIME);
PORTC=0;
delay_us(LED_TIME);
}
}
//function Delay
void delay_us (unsigned int cntr)
{
while (--cntr != 0)
;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -