Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- The SparkFun WVR is an audio development board with Wi-Fi capabilities. It supports several kinds of audio inputs and outputs.
- Please ensure you have installed the SparkFun WVR library from the Arduino library manager before uploading this code.
- This example will play the test.wav file when the button on pin 0 is pressed and stop the audio when the button on pin 1 is pressed. Please replace "/sd/test.wav" with the path to your actual audio file on the SD card. This example assumes the buttons are active high, meaning the signal is HIGH (3.3V) when the button is pressed and LOW (0V) when not pressed. If your buttons are wired differently, you may need to adjust the conditions in the if statements.
- */
- #include <SparkFun_WVR.h>
- WVR wvr;
- // Define button pins
- #define BUTTON_PLAY_PIN 0
- #define BUTTON_STOP_PIN 1
- void setup() {
- // Start WVR
- wvr.begin();
- // Wait for SD card to initialize
- while (!wvr.sdBegin()) {
- delay(1000);
- }
- // Set up button pins as input
- wvr.pinMode(BUTTON_PLAY_PIN, INPUT);
- wvr.pinMode(BUTTON_STOP_PIN, INPUT);
- }
- void loop() {
- // Check the state of the buttons
- if (wvr.digitalRead(BUTTON_PLAY_PIN) == HIGH) {
- // If the play button is pressed and WVR is not currently playing
- if (!wvr.isPlaying()) {
- // Play file from SD card
- wvr.playFile("/sd/test.wav");
- }
- }
- if (wvr.digitalRead(BUTTON_STOP_PIN) == HIGH) {
- // If the stop button is pressed and WVR is currently playing
- if (wvr.isPlaying()) {
- // Stop playback
- wvr.stopPlayback();
- }
- }
- // Small delay before loop repeats
- delay(50);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement