Difference between revisions of "Matrix - Ultrasonic Ranger"
From FriendlyELEC WiKi
(→连接) |
|||
Line 1: | Line 1: | ||
+ | [[Matrix - Ultrasonic Ranger/zh|查看中文]] | ||
+ | |||
==介绍== | ==介绍== | ||
[[File:UltrasonicRanger.png|thumb|Ultrasonic Ranger]] | [[File:UltrasonicRanger.png|thumb|Ultrasonic Ranger]] |
Revision as of 08:11, 7 August 2015
Contents
1 介绍
TODO
2 特性
- 特性1
- 特性2
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上传到开发板上运行即可测试。