Skip to main content

This is tracker driver for HaaS Python. HaaS Python is forked from micropython.

Project description

HaaS Python介绍

HaaS Python是阿里云IoT团队最新研发的一套低代码编程框架,兼容MicroPython编程规范,依托HaaS平台软硬件积木提供AI、支付、蓝牙配网、云连接、UI等物联网场景常用的能力,从而解决了物联网应用开发难的问题。有了Python轻应用框架,物联网编程不再局限于专业软件开发人员,一般的技术员也可以快速实现复杂的物联网需求。 更多HaaS Python介绍和开发资料见HaaS Python官网,创意案例, 硬件积木

HaaS Python is a set of low-code programming frameworks newly developed by Alibaba Cloud IoT team. It is compatible with MicroPython programming specifications. It relies on the hardware and software building blocks of the HaaS platform to provide capabilities commonly used in IoT scenarios such as AI, payment, Bluetooth network configuration, cloud connection, and UI. Solve the difficult problem of IoT application development. With the Python light application framework, IoT programming is no longer limited to professional software developers, and general technicians can quickly implement complex IoT requirements. For more HaaS Python introduction and development materials, see HaaS Python official website, Creative Case, Hardware Building Blocks

安装方法

Download the firmware corresponding to the development board at HaaS Python website and complete the firmware burning

  • 在开发板上运行以下命令完成安装和使用,如果您在使用过程中遇到问题,欢迎在github上向我们提交issue,我们的工程师会及时解答

Run the following commands on the development board to complete the installation and use. If you encounter problems during use, please submit an issue to us on github, Our engineers will answer in time

import upip
upip.install("haas-python-tracker")
import haas-python-tracker

黑白循迹传感器

一、产品简介

   黑白循迹传感器具有一对红外线发射与接收管,发射管不断发射出红外线,当发射出的红外线没有被反射回来或给反射回来强度不大时,红外接收管一直处于关断状态,此时模块的输出端为低电平;当发射出的红外线被检测物阻挡发射回来强度足够大的时候,红外接收管达到饱和状态,模块输出高电平。黑白循迹传感器可以广泛应用于机器人避障、避障小车、流水线计数及黑白线循迹等众多场合。

引脚定义

  • VCC:3.3V
  • GND:地
  • OUT:输出信号

二、技术参数

  • 工作电压:3.3V-5V
  • 有效检测距离:1mm-25mm
  • 输出电平:TTL
  • 工作温度:-20°C~85°C
  • 电路板尺寸:35mm*10mm

三、软件接口

黑白循迹传感器HaaS Python驱动:下载地址

TRACKER(gpioObj) - 创建黑白循迹传感器对象


  • 函数原型

trackerDev = TRACKER(gpioObj)

  • 参数说明
参数 类型 必选参数? 说明
gpioObj GPIO 调用此函数前需确保gpioObj对象已经处于open状态
  • 返回值

TRACKER对象成功,返回TRACKER对象;TRACKER对象创建失败,抛出Exception

  • 示例代码
from driver import GPIO     # 驱动库
import tracker

gpioObj = GPIO()
gpioObj.open("tracker")    # 按照board.json中名为"tracker"的设备节点的配置参数
print("GPIO inited!")

trackerDev= tracker.TRACKER(gpioObj)
  • 输出
GPIO inited!

objectDetection() - 获取黑白循迹传感器的状态


  • 函数功能:

获取黑白循迹传感器的状态

  • 函数原型:

TRACKER.getTrackerStatus()

  • 参数说明:

  • 返回值:

成功返回黑白循迹传感器的状态,0 - 白线 1 - 黑线;失败抛出Exception

  • 示例:
from driver import GPIO     # 驱动库
import tracker

gpioObj = GPIO()
gpioObj.open("tracker")    # 按照board.json中名为"tracker"的设备节点的配置参数
print("GPIO inited!")

trackerDev= tracker.TRACKER(gpioObj)
status = trackerDev.getTrackerStatus()
print("Tracker status is :%d level"%(status))
  • 输出
GPIO inited!
Tracker status is :0 level

四、接口案例

此使用实例在board.json中定义了名为TRACKER的GPIO类型的对象。在Python脚本中获取黑白循迹传感器的状态值并打印在日志中。

  • 案例代码
{
  "name": "board-name",
  "version": "1.0.0",
  "io": {
   "tracker":{
        "type": "GPIO",
        "port": 0,
        "dir": "input",
        "pull": "opendrain"
    }
  }
}
from driver import GPIO     # 驱动库
import tracker
import utime

gpioObj = GPIO()
gpioObj.open("tracker")    # 按照board.json中名为"tracker"的设备节点的配置参数
print("GPIO inited!")

trackerDev= tracker.TRACKER(gpioObj)
while True:
    status = trackerDev.getTrackerStatus()
    print("Tracker status is :%d level"%(status))
    utime.sleep(1)
  • 输出
GPIO inited!
Tracker status is :0 level
Tracker status is :0 level
Tracker status is :1 level
Tracker status is :1 level
Tracker status is :1 level
Tracker status is :1 level
Tracker status is :0 level
Tracker status is :0 level
Tracker status is :0 level

参考文献及购买链接

[1] 购买链接

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

haas-python-tracker-0.0.7.tar.gz (7.7 kB view details)

Uploaded Source

File details

Details for the file haas-python-tracker-0.0.7.tar.gz.

File metadata

  • Download URL: haas-python-tracker-0.0.7.tar.gz
  • Upload date:
  • Size: 7.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.0 CPython/3.8.5

File hashes

Hashes for haas-python-tracker-0.0.7.tar.gz
Algorithm Hash digest
SHA256 22bcdd3b7093a58f6320fae094d014a1805b4706f855968697b8405a5886fac5
MD5 1c6f5dbe23ac10ba7326e197313cadcd
BLAKE2b-256 739c15e863bd1e951a36902160304c7a669c76603a70fd7d9bbc1c5ab9d02e1b

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page