からから 英国から DEから ITから FRから ESから JPから


このレッスンでは、アナログモードを使用して音を検出する方法を示しますマイクセンサーは周囲の音の強さを検出し、音の強さが特定のしきい値を超えるとLEDを点灯します。

変化は非常に弱いので、増幅する必要があります。ポテンショメータを調整することで、で感度を調整できます。サウンドレベルが設定値を超えると、センサーモジュールのLEDが点灯し、出力がローに送信されます。

First you need insert the OSOYOO Magic I/O shield into UNO board. Then plug the sound sensor module to A0 port of the Magic I/O shield with a 3-pin PNP cable as following:

Notice: Shut off your battery or Unplug your power adapter when upload sketch code to Arduino.

You can download the code directly, then click “Open” in Mixly to choose the code you download:

Download the Code

Or you can do as following operations:

After above operations are completed, connect the Arduino board to your computer using the USB cable. The green power LED (labelled PWR) should go on.Open the Graphical Programming software Mixly and follow the next operations:

Drag out the Serial printIn block from the SerialPort category ,set pin 3 as input.

Drag out the AnalogRead PIN# block from the In/Out category ,set pin A0 as input.


Drag out the if block from the Control category and drag out the first block in Logic category.


Drag out the AnalogRead PIN# block from the In/Out category ,set pin A0 as input.

Then Drag out the 0 block from Math Category, set 600 as value.


Drag out a DigitalWrite PIN# block from the In/Out category ,set pin 13 as input, HIGH as stat.

Then drag out the Delay block from Control Category,set 3000 as value.

We also need add an else sub-block to this if do block. To do this, just click the setting icon inside if do block, drag out an else sub-block and connect it to if block, then Click setting again to turn off the setting window.

Drag out the DigitalWrite PIN# block from the In/Out category ,set pin 13 as input, LOW as stat.


Save and upload program to Arduino board.

You can open the Serial Monitor by going to Tools > Serial Monitor or pressing the magnifying glass-button in the Arduino software window.

What prints out is the analog and digital values of from the sound sensor module. The analog value should spike up when a noise occurs and stabilize when it gets quiet again.

After uploading this code, when the volume reaches to a certain value (sometimes you need to blow a breath to make the sound loudly), the LED attached to pin 13 on the Uno board will light up. If the sound does not sense very well, try changing the threshold value or changing the sensor sensitivity by rotating the potentiometer in the module .

これで、コードに「AnalogRead(A0)> 600」行きがありんます。これは、非常に近いが、周囲が静かなときにシリアルモニターから取得する値よりも高い値に変更する必要がありますたとえば、アナログが600の表、Pplowose表603でき605にありますこと、われ、あります。音が発生する、アナログ値がするし、パズルをしたます。私があり、あなたのLEDはオンになりました。なります。再び静かになると、アナログ値は603に戻り、LEDは再び暗くなります