Matrix - Sound Sensor

From FriendlyELEC WiKi
Revision as of 09:10, 27 July 2015 by Tzs (Talk | contribs) (Created page with "==介绍== Sound Sensor TODO ==特性== * 特性1 * 特性2 ==使用方法== ===连接=== *连接到Tiny4412 SDK (1506) ::GND针脚: 接地...")

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

1 介绍

Sound Sensor

TODO

2 特性

  • 特性1
  • 特性2

3 使用方法

3.1 连接

  • 连接到Tiny4412 SDK (1506)
GND针脚: 接地
VCC: 接5V
S: GPIO PIN1

3.2 Linux下的C示例

#include <stdio.h>
#include "libfahw.h"
 
static struct sensor sound[] = {
        {
                TINY4412_GPIO_PIN1,
                IRQ_TYPE_EDGE_BOTH,
        }
};
 
int main(void)
{
    int i;
    int retSize = -1;
    char value[ARRAY_SIZE(sound)];
    int devFD = -1;
    if ((devFD =sensorInit(sound, ARRAY_SIZE(sound))) == -1) {
        printf("Fail to init sensor\n");
        return -1;
    }
 
    if (( retSize = sensorRead(devFD, value, ARRAY_SIZE(sound)) ) == -1) {
        printf("Fail to read sensors\n");
    }
    if (retSize > 0) {
        i = 0;
        for(i=0; i<retSize; i++)
        {
            printf("sound[%d]:%d\n", i, value[i]);
        }
        printf("\n");
    }
    sensorDeinit(devFD);
    return 0;
}

3.3 编译并运行示例

git clone http://github.com/friendlyarm/fa-hardware.git
cd fa-hardware
cd demo
cd matrix-sound_sensor
make

将编译生成的sound通过ftp上传到开发板上运行即可测试。

4 相关资料