Example Code for Arduino-Voice Playback Trigger
Last revision 2026/01/07
The article guides readers through setting up a voice playback trigger using Arduino. It covers hardware and software preparation, the wiring process, and provides sample code to implement voice recording and playback functionality.
Hardware Preparation
- DFRduino UNO x1
- IO expansion shield V7 x1
Software Preparation
- Arduino IDE V1.6.5 Click to Download Arduino IDE from Arduino
Wiring Diagram

Other Preparation Work
- Press and hold the recording button, and the onboard microphone will pick up external voice signals to realize the recording function. Release the recording button or the recording time has reached 20 seconds, and the yellow LED on the board will go out to indicate the end of recording.
- Press the play button to play the recorded voice clip. After the playback ends, the yellow LED on the board will go out.
Sample Code
int Play_pin = 2;
void setup() {
pinMode(Play_pin, OUTPUT);
digitalWrite(Play_pin, HIGH);
}
void loop() {
digitalWrite(Play_pin, LOW); //Comment this sentence and the recording will not be played automatically
delay(200);
digitalWrite(Play_pin, HIGH);
delay(20000);
}
Was this article helpful?
