#include "stm32f10x.h"
#include "stm32f10x_tim.h"
#include "delay.h"
#include "OLED.h"
#include "pwm_led.h"
uint8_t i; //定义for循环的变量
int main (void)
{
/*模块初始化*/
OLED_Init();
PWM_Init();
while(1)
{
for (i = 0; i <= 100; i++)
{
PWM_SetCompare1(i); //依次将定时器的CCR寄存器设置为0~100,PWM占空比逐渐增大,LED逐渐变亮
delay_ms(10); //延时10ms
}
for (i = 0; i <= 100; i++)
{
PWM_SetCompare1(100 - i); //依次将定时器的CCR寄存器设置为100~0,PWM占空比逐渐减小,LED逐渐变暗
delay_ms(10); //延时10ms
}
}
}