欧美极品高清xxxxhd,国产日产欧美最新,无码AV国产东京热AV无码,国产精品人与动性XXX,国产传媒亚洲综合一区二区,四库影院永久国产精品,毛片免费免费高清视频,福利所导航夜趣136
標題:
STM32單片機LED流水燈程序(循環亮)
[打印本頁]
作者:
元元元。。。
時間:
2023-6-26 18:50
標題:
STM32單片機LED流水燈程序(循環亮)
單片機源程序如下:
/*******************************************************************************
* 實 驗 名 : 庫函數模板創建
* 實驗說明 :
* 連接方式 :
* 注 意 :
*******************************************************************************/
#include "stm32f4xx.h"
/*******************************************************************************
* 函 數 名 : delay_ms
* 函數功能 : 延時函數(單位ms)
* 輸 入 : time
* 輸 出 : 無
*******************************************************************************/
void delay_ms(u32 time)
{
u32 i=0;
while(time--)
{
i=32000;
while(i--);
}
}
/*******************************************************************************
* 函 數 名 : led_Init
* 函數功能 : led所接GPIO初始化
* 輸 入 : 無
* 輸 出 : 無
*******************************************************************************/
void led_Init(void)
{
GPIO_InitTypeDef GPIO_InitStructure; //定義結構體變量
RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOF,ENABLE); //使能端口F時鐘
GPIO_InitStructure.GPIO_Mode=GPIO_Mode_OUT; //輸出模式
GPIO_InitStructure.GPIO_Pin=GPIO_Pin_8|GPIO_Pin_9|GPIO_Pin_10|GPIO_Pin_11|GPIO_Pin_12|GPIO_Pin_13|GPIO_Pin_14|GPIO_Pin_15;//管腳設置F8-F13
GPIO_InitStructure.GPIO_Speed=GPIO_Speed_100MHz;//速度為100M
GPIO_InitStructure.GPIO_OType=GPIO_OType_PP;//推挽輸出
GPIO_InitStructure.GPIO_PuPd=GPIO_PuPd_UP;//上拉
GPIO_Init(GPIOF,&GPIO_InitStructure); //初始化結構體
GPIO_SetBits(GPIOF,GPIO_Pin_8|GPIO_Pin_9|GPIO_Pin_10|GPIO_Pin_11|GPIO_Pin_12|GPIO_Pin_13|GPIO_Pin_14|GPIO_Pin_15); //關閉LED
}
/*******************************************************************************
* 函 數 名 : main
* 函數功能 : 主函數
* 輸 入 : 無
* 輸 出 : 無
*******************************************************************************/
int main()
{
SystemInit(); //系統時鐘初始化
led_Init(); //LED初始化
while(1)
{
GPIO_Write(GPIOF,0xfeff);
delay_ms(600);
GPIO_Write(GPIOF,0xfdff);
delay_ms(600);
GPIO_Write(GPIOF,0xfbff);
delay_ms(600);
GPIO_Write(GPIOF,0xf7ff);
delay_ms(600);
GPIO_Write(GPIOF,0xefff);
delay_ms(600);
GPIO_Write(GPIOF,0xdfff);
delay_ms(600);
GPIO_Write(GPIOF,0xbfff);
delay_ms(600);
GPIO_Write(GPIOF,0x7fff);
delay_ms(600);//0.6左流水
}
}
復制代碼
Keil代碼下載:
流水單循環亮.7z
(362.73 KB, 下載次數: 22)
2023-6-29 02:34 上傳
點擊文件名下載附件
下載積分: 黑幣 -5
歡迎光臨 (http://www.raoushi.com/bbs/)
Powered by Discuz! X3.1