Difference between revisions of "Matrix - Ultrasonic Ranger"
From FriendlyELEC WiKi
(→使用方法) |
|||
Line 9: | Line 9: | ||
* 特性2 | * 特性2 | ||
− | == | + | ==How To== |
− | === | + | ===Connection=== |
− | * | + | *Connect to Tiny4412 SDK (1506) |
− | :: | + | ::GND: Ground |
− | ::VCC: | + | ::VCC: 5V |
::ECHO: GPIO PIN1 | ::ECHO: GPIO PIN1 | ||
::TRIG: GPIO PIN2 | ::TRIG: GPIO PIN2 | ||
− | === | + | ===Code Sample in C Under Linux=== |
<syntaxhighlight lang="c"> | <syntaxhighlight lang="c"> | ||
#include <stdio.h> | #include <stdio.h> | ||
Line 44: | Line 44: | ||
</syntaxhighlight> | </syntaxhighlight> | ||
− | === | + | ===Compile and Run=== |
<syntaxhighlight lang="bash"> | <syntaxhighlight lang="bash"> | ||
git clone http://github.com/friendlyarm/fa-hardware.git | git clone http://github.com/friendlyarm/fa-hardware.git | ||
Line 52: | Line 52: | ||
make | make | ||
</syntaxhighlight> | </syntaxhighlight> | ||
− | + | Copy your compiled bin to your board and you are ready to go. | |
==相关资料== | ==相关资料== |
Revision as of 08:16, 7 August 2015
Contents
1 介绍
TODO
2 特性
- 特性1
- 特性2
3 How To
3.1 Connection
- Connect to Tiny4412 SDK (1506)
- GND: Ground
- VCC: 5V
- ECHO: GPIO PIN1
- TRIG: GPIO PIN2
3.2 Code Sample in C Under Linux
#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 Compile and Run
git clone http://github.com/friendlyarm/fa-hardware.git cd fa-hardware cd demo cd matrix-ultrasonic_ranger make
Copy your compiled bin to your board and you are ready to go.