官术网_书友最值得收藏!

Testing the microphone

We are now going to make sure that the microphone is working correctly and especially check whether it can record voice levels, for example. I had a problem when I was testing the prototype of this project with a microphone that wasn't amplified; I just couldn't hear anything on the recording.

The first step is to plug the microphone into the Arduino board. There are 3 pins to connect the microphone: VCC, GND, and AUD. Connect VCC to the Arduino 5V pin, GND to the Arduino GND pin, and AUD to the Arduino analog pin A5.

The following is a schematic to help you out:

Here is an image of the final result:

We are now going to use a very simple sketch to read out the signal from the microphone and print it on the serial monitor:

// Microphone test

void setup() {
 
  // Start Serial
  Serial.begin(115200);
}

void loop() {
 
  // Read the input on analog pin 5:
  int sensorValue = analogRead(A5);
 
  // Print out the value you read:
  Serial.println(sensorValue);
  delay(1);        // delay in between reads for stability
}

This sketch, basically, continuously reads the data from the A5 pin, where the microphone is connected, and prints it on the serial monitor.

Now, copy and paste this sketch in the Arduino IDE and upload it to the board. Also, open the serial monitor.

The following is the result on the serial monitor:

While looking at the serial monitor, speak around the microphone. You should immediately see some variations in the signal that is read by the board. This means that your voice is being recorded by the microphone and the amplification is sufficient for the microphone to record a normal voice level.

主站蜘蛛池模板: 长海县| 西畴县| 湛江市| 黎平县| 阿拉尔市| 循化| 来安县| 喀喇沁旗| 辉县市| 英德市| 拜泉县| 文山县| 临城县| 正蓝旗| 易门县| 五家渠市| 富民县| 丹巴县| 荃湾区| 安新县| 沙河市| 麻城市| 文成县| 固镇县| 耿马| 苍南县| 汝城县| 秦皇岛市| 鄂温| 灵璧县| 横山县| 义乌市| 东莞市| 白山市| 东乡族自治县| 永寿县| 沈阳市| 南郑县| 嵊泗县| 嘉禾县| 永丰县|