標(biāo)題:
stm32 oled顯示呼吸燈
[打印本頁]
作者:
可愛小馬
時(shí)間:
2021-7-22 17:15
標(biāo)題:
stm32 oled顯示呼吸燈
stm32 oled顯示呼吸燈
#include "stm32f10x.h"
#include "led.h"
#include "delay.h"
#include "sys.h"
#include "usart.h"
#include "timer.h"
#include "oled.h"
int main(void)
{
u16 led0pwmval=0;
u8 dir=1;
delay_init(); //延時(shí)函數(shù)初始化
OLED_Init();
LED_Init(); //LED端口初始化
TIM3_PWM_Init(899,0); //不分頻。PWM頻率=72000000/900=80Khz
OLED_ColorTurn(0);//0正常顯示,1 反色顯示
OLED_DisplayTurn(0);//0正常顯示 1 屏幕翻轉(zhuǎn)顯示
while(1)
{
delay_ms(10);
if(dir)led0pwmval++;
else led0pwmval--;
if(led0pwmval>300)dir=0;
if(led0pwmval==0)dir=1;
TIM_SetCompare2(TIM3,led0pwmval);
OLED_Refresh();
delay_ms(500);
OLED_Clear();
OLED_ShowString(0,0,"PWM:",16,1);
OLED_ShowNum(40,0,led0pwmval,3,16,1);
}
}
復(fù)制代碼
下載:
OLED顯示呼吸燈.7z
(193.38 KB, 下載次數(shù): 24)
2021-7-22 23:29 上傳
點(diǎn)擊文件名下載附件
下載積分: 黑幣 -5
作者:
BCWGTeam
時(shí)間:
2023-9-16 21:48
沒看懂啊
歡迎光臨 (http://www.torrancerestoration.com/bbs/)
Powered by Discuz! X3.1