tiandsp

寻迹模块如下:

树莓派的引脚如下图:

我们将Vcc引脚连接物理接口2,GND引脚连接物理接口39,DO引脚连接物理接口40。

实物连接如下图:

编程使用WiringPi库,使用wpi引脚编码方式控制GPIO。

代码如下:

#include <wiringPi.h>
#include <stdio.h>
#include <sys/time.h>

#define TRACKER    29

int main(void)
{

    if (wiringPiSetup() == -1) 
    { 
        printf("setup wiringPi failed !");
        return 1; 
    }
    
    pinMode(TRACKER, INPUT);        
    
    while (1) 
    {
        if (digitalRead(TRACKER) == 0)
        {
            printf("no tracker\n");
            delay(333);
        }
        else
        {
            printf("trackered\n");
            delay(333);
        }
    }
        
    return 0;
}

输出结果:

分类:

技术点:

相关文章:

  • 2021-12-12
  • 2022-12-23
  • 2021-07-29
  • 2021-11-15
  • 2021-11-14
  • 2021-11-20
  • 2021-10-12
猜你喜欢
  • 2021-06-26
  • 2021-05-18
  • 2022-03-14
  • 2022-03-15
  • 2021-10-27
  • 2022-03-14
  • 2021-05-26
相关资源
相似解决方案