我是用8路灰度传感器的其中一个引脚作为信号,当它亮灯的时候点亮一盏灯,不亮的时候点亮另一盏灯。
但是现象就是无论亮灯还是不亮灯,都只是一盏灯会亮。
程序代码如下
main.c
#include "sys.h"
#include "delay.h"
#include "usart.h"
#include "led.h"
#include "8road.h"
int main(void)
{
u16 ReadValue;
ReadValue = GPIO_ReadInputDataBit(GPIOA,GPIO_Pin_0);
LED_Init();
OUT_Init();
while(1)
{
if(ReadValue == 0)
LED1=0;
else
LED0=0;
}
}
8road.c
#include "8road.h"
void OUT_Init(void)
{
GPIO_InitTypeDef GPIO_InitStructure;
RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOA, ENABLE);//ê1ÄüGPIOFê±Öó
//GPIOF9,F103õê¼»ˉéèÖÃ
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_0;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN;//ÆÕí¨êäèëÄ£ê½
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_100MHz;//100MHz
GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_NOPULL;
GPIO_Init(GPIOF, &GPIO_InitStructure);//3õê¼»ˉGPIO
}
友情提示: 此问题已得到解决,问题已经关闭,关闭后问题禁止继续编辑,回答。
对喔,谢谢谢谢
一周热门 更多>