STM32怎么讀取紅外避障輸入到io口的電平啊,最近在做紅外避障小車,新手,不會做,,,
下面是其中一個io口的程序
{ void HWBZ_Init(void);
GPIO_InitTypeDef GPIO_InitStructure;
RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOE,ENABLE);//使能PE端時鐘
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_1; // HWBZ-->PE1 端口配置
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IPU; // 上拉輸入
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz; //IO口速度為50MHz
GPIO_Init(GPIOE,&GPIO_InitStructure); //根據參數設定初始化GPIOE1
} |