weixin_44961057 2019-11-15 20:22 采纳率: 0%
浏览 280

sr501没有办法拉高电平

手在前面晃,只能输出低电平,无法拉高IO

#include "stm32f4xx.h"
#include "led.h"
#include "delay.h"
//#include "beep.h"
#include "usart.h"

int main(void)
{
delay_init(156);
uart_init(115200);
// beep_Init();
LED_Init();
while(1)
{
if(L_XHG==1)
{
LED=0;
printf("true\r\n");
}
if(L_XHG==0)
{
LED=1;
printf("error");
delay_ms(100);
}
}

}

#include "led.h"
#include "stm32f4xx.h"

void LED_Init(void)
{
GPIO_InitTypeDef GPIO_Initstrtype;

RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOF,ENABLE);
RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOA,ENABLE);

GPIO_Initstrtype.GPIO_Mode=GPIO_Mode_OUT;
GPIO_Initstrtype.GPIO_OType=GPIO_OType_PP;
GPIO_Initstrtype.GPIO_Pin=GPIO_Pin_9;
GPIO_Initstrtype.GPIO_PuPd=GPIO_PuPd_UP;
GPIO_Initstrtype.GPIO_Speed=GPIO_Speed_100MHz;

GPIO_Init(GPIOF,&GPIO_Initstrtype);

GPIO_Initstrtype.GPIO_Mode=GPIO_Mode_IN;
GPIO_Initstrtype.GPIO_Pin=GPIO_Pin_0;
GPIO_Initstrtype.GPIO_PuPd=GPIO_PuPd_DOWN;
GPIO_Initstrtype.GPIO_Speed=GPIO_Speed_100MHz;

GPIO_Init(GPIOA,&GPIO_Initstrtype);
}

#ifndef __LED_H

#define __LED_H

#define L_XHG PAin(0)
#define LED PFout(9)

void LED_Init(void);

#endif

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 求解 yolo算法问题
    • ¥15 虚拟机打包apk出现错误
    • ¥30 最小化遗憾贪心算法上界
    • ¥15 用visual studi code完成html页面
    • ¥15 聚类分析或者python进行数据分析
    • ¥15 三菱伺服电机按启动按钮有使能但不动作
    • ¥15 js,页面2返回页面1时定位进入的设备
    • ¥50 导入文件到网吧的电脑并且在重启之后不会被恢复
    • ¥15 (希望可以解决问题)ma和mb文件无法正常打开,打开后是空白,但是有正常内存占用,但可以在打开Maya应用程序后打开场景ma和mb格式。
    • ¥20 ML307A在使用AT命令连接EMQX平台的MQTT时被拒绝