Difference between revisions of "Matrix - Ultrasonic Ranger"

From FriendlyELEC WiKi
Jump to: navigation, search
(使用方法)
(相关资料)
Line 54: Line 54:
 
Copy your compiled bin to your board and you are ready to go.
 
Copy your compiled bin to your board and you are ready to go.
  
==相关资料==
+
==Resources==

Revision as of 08:16, 7 August 2015

查看中文

1 介绍

Ultrasonic Ranger

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.

4 Resources