Matrix - Ultrasonic Ranger
From FriendlyELEC WiKi
Revision as of 08:33, 27 July 2015 by Tzs (Talk | contribs) (Created page with "==介绍== Ultrasonic Ranger TODO ==特性== * 特性1 * 特性2 ==使用方法== ===连接=== *连接到Tiny4412 SDK (1506) ::GND针脚:...")
Contents
1 介绍
TODO
2 特性
- 特性1
- 特性2
3 使用方法
3.1 连接
- 连接到Tiny4412 SDK (1506)
- GND针脚: 接地
- VCC: 接5V
- TRIG: GPIO PIN1
- ECHO: GPIO PIN2
3.2 Linux下的C示例
#include <stdio.h> #include <unistd.h> #include "libfahw.h" int main(int argc, char ** argv) { int distance = -1; int echoPin = TINY4412_GPIO_PIN1; int triggerPin = TINY4412_GPIO_PIN2; if (Hcsr04Init(echoPin, triggerPin) == -1) { printf("Fail to init hcsr04\n"); } if (Hcsr04Read(&distance)==0 && distance != -1) { printf("Get distance: %3d cm\n", distance); } else { printf("Faid to get distance\n"); } Hcsr04DeInit(); return 0; }
3.3 编译并运行示例
git clone http://github.com/friendlyarm/fa-hardware.git cd fa-hardware cd demo cd matrix-ultrasonic_ranger make
将编译生成的hcsr04通过ftp上传到开发板上运行即可测试。