Difference between revisions of "Matrix - Ultrasonic Ranger/zh"
From FriendlyELEC WiKi
(Created page with "English ==介绍== Ultrasonic Ranger TODO ==特性== * 特性1 * 特性2 ==使用方法== ===连接=== *...") |
(→特性) |
||
Line 8: | Line 8: | ||
* 特性1 | * 特性1 | ||
* 特性2 | * 特性2 | ||
+ | * PCB尺寸(mm):20x40 | ||
+ | [[File:ultpcb.png|frameless|400px|超声波PCB]] | ||
==使用方法== | ==使用方法== |
Revision as of 10:47, 12 August 2015
Contents
1 介绍
TODO
2 特性
- 特性1
- 特性2
- PCB尺寸(mm):20x40
3 使用方法
3.1 连接
- 连接到Tiny4412 SDK (1506)
- GND针脚: 接地
- VCC: 接5V
- ECHO: GPIO PIN1
- TRIG: 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上传到开发板上运行即可测试。