Difference between revisions of "Matrix - Sound Sensor"

From FriendlyELEC WiKi
Jump to: navigation, search
(Introduction)
Line 3: Line 3:
 
==Introduction==
 
==Introduction==
 
[[File:SoundSensor01.png|thumb|Sound Sensor]]
 
[[File:SoundSensor01.png|thumb|Sound Sensor]]
配件在默认状态下输出高电平,当检测到有声音的时候输出低电平,声音消失后恢复高电平,没有延时。配件上面的可调电阻可以调整检测的阈值,也即音量。顺时针旋转可调电阻增大阈值,可检测到的声音音量越大,反之越小。
+
By default this module's output level is high. When it detects sound signals its output level will turn low. When sound signals are not detected its output will turn high again without time delay. There is a variable resistor which you can use to control the threshold value of a sound volume. Only when a sound volume's value is greater than this threshold value the module can detect it. Turning clockwise increases this threshold value. Turning anticlockwise decreases this value.
By default its output is high level. When it detects sound signals its output becomes low. When sound signals are off its output becomes high and it doesn't have any delay.
+
  
 
==特性==
 
==特性==

Revision as of 10:35, 4 August 2015

查看中文

1 Introduction

Sound Sensor

By default this module's output level is high. When it detects sound signals its output level will turn low. When sound signals are not detected its output will turn high again without time delay. There is a variable resistor which you can use to control the threshold value of a sound volume. Only when a sound volume's value is greater than this threshold value the module can detect it. Turning clockwise increases this threshold value. Turning anticlockwise decreases this value.

2 特性

  • 阈值可调,即时响应
  • 2.54mm排针接口,接线方便,通用性强

3 使用方法

3.1 连接

  • 连接到Tiny4412 SDK (1506)
G: 接地
V: 接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 相关资料