找回密码
 立即注册

QQ登录

只需一步,快速开始

搜索
查看: 872|回复: 0
打印 上一主题 下一主题
收起左侧

共享适用于stm32f10x单片机的trct5000红外追迹驱动代码

[复制链接]
跳转到指定楼层
楼主
ID:1086422 发表于 2023-6-28 23:35 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
如题,最近用到trct5000红外追迹模块,到处找不到代码,最后,在xxdn上下载下来用了,优化了些代码
现在共享出来,希望有用的着的朋友们支持一下

单片机源程序如下:
  1. //硬件驱动
  2. #include "usart.h"
  3. #include "common_.h"
  4. #include "TCRT5000.h"

  5. int last_on_status;

  6. void Tcrt_Init(void)
  7. {
  8.         GPIO_InitTypeDef GPIO_InitStructure;

  9.         RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOA, ENABLE); // pa
  10.         
  11.         GPIO_InitStructure.GPIO_Pin = GPIO_Pin_1; // pa01->d0
  12. //        GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IPD;//上拉输入
  13.         GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IPU;// 下拉输入
  14.         GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
  15.         GPIO_Init(GPIOA,&GPIO_InitStructure);
  16.         
  17.         last_on_status = 0;// 默认下拉
  18. }

  19. void Tcrt_test(){
  20.         
  21.         int on_status = 0;
  22.         if(TCRT1 == 0) //循迹到黑线
  23.         {
  24. //                print_str("感应到物体接近...");
  25.                 on_status = 1;
  26.         }else if(TCRT1 == 1) //未循迹到黑线
  27.         {
  28. //                print_str("物体离开...");
  29.                 on_status = 0;
  30.         }
  31.         

  32.         process_trct(on_status, on_status != last_on_status);
  33.         
  34.         last_on_status = on_status;
  35. }
复制代码


评分

参与人数 1黑币 +50 收起 理由
admin + 50 共享资料的黑币奖励!

查看全部评分

分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏 分享淘帖 顶 踩
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

手机版|小黑屋|51黑电子论坛 |51黑电子论坛6群 QQ 管理员QQ:125739409;技术交流QQ群281945664

Powered by 单片机教程网

快速回复 返回顶部 返回列表