声音检测传感器
概述声音检测传感器模块。能检测声音的强弱,不能识别指定的声音。
规格
开发设备
准备
实验:检测声音大小
#define mic_pin A0
int sensorValue;
// the setup routine runs once when you press reset:
void setup() {
// initialize serial communication at 9600 bits per second:
Serial.begin(9600);
pinMode(mic_pin, INPUT);
}
// the loop routine runs over and over again forever:
void loop() {
// read the input on analog pin 0:
sensorValue = analogRead(mic_pin);
// print out the value you read:
Serial.print("Sound:");
Serial.println(sensorValue);
delay(100); // delay in between reads for stability
}
程序调试
视频 |