找回密碼
 立即注冊(cè)

QQ登錄

只需一步,快速開(kāi)始

搜索
查看: 1548|回復(fù): 0
打印 上一主題 下一主題
收起左側(cè)

共享適用于stm32f10x單片機(jī)的trct5000紅外追跡驅(qū)動(dòng)代碼

[復(fù)制鏈接]
跳轉(zhuǎn)到指定樓層
樓主
ID:1086422 發(fā)表于 2023-6-28 23:35 | 只看該作者 回帖獎(jiǎng)勵(lì) |倒序?yàn)g覽 |閱讀模式
如題,最近用到trct5000紅外追跡模塊,到處找不到代碼,最后,在xxdn上下載下來(lái)用了,優(yōu)化了些代碼
現(xiàn)在共享出來(lái),希望有用的著的朋友們支持一下

單片機(jī)源程序如下:
  1. //硬件驅(qū)動(dòng)
  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;// 默認(rèn)下拉
  18. }

  19. void Tcrt_test(){
  20.         
  21.         int on_status = 0;
  22.         if(TCRT1 == 0) //循跡到黑線
  23.         {
  24. //                print_str("感應(yīng)到物體接近...");
  25.                 on_status = 1;
  26.         }else if(TCRT1 == 1) //未循跡到黑線
  27.         {
  28. //                print_str("物體離開(kāi)...");
  29.                 on_status = 0;
  30.         }
  31.         

  32.         process_trct(on_status, on_status != last_on_status);
  33.         
  34.         last_on_status = on_status;
  35. }
復(fù)制代碼


評(píng)分

參與人數(shù) 1黑幣 +50 收起 理由
admin + 50 共享資料的黑幣獎(jiǎng)勵(lì)!

查看全部評(píng)分

分享到:  QQ好友和群QQ好友和群 QQ空間QQ空間 騰訊微博騰訊微博 騰訊朋友騰訊朋友
收藏收藏 分享淘帖 頂 踩
回復(fù)

使用道具 舉報(bào)

本版積分規(guī)則

手機(jī)版|小黑屋|51黑電子論壇 |51黑電子論壇6群 QQ 管理員QQ:125739409;技術(shù)交流QQ群281945664

Powered by 單片機(jī)教程網(wǎng)

快速回復(fù) 返回頂部 返回列表