i want to design an audio player or say a wav player just as per diagram above . .
A bit explanation is here below :-
Pin 9 - 13 is engaged with SD Card module unit
Inside SD Card 4 or 5 folders with name A, B, C, D or 01, 02, 03, 04, . . or anything like that and each of them ll have 5 audio files in wave format with same file name say, 1, 2, 3, 4, 5 . . .
[Note :- Naming Files with same name in each folder is for compatibility of code]
Ahead,
On the right most side the Arduino there exist 2 buttons with labelled next and previous are for selecting a folder in order say, A B C D or 01 02 03 04 and so on.
Now with buttons from 2 to 6 we ll be able to trigger individual audio files from the selected folder
It means that the triggering buttons from 2 to 6 ll be same all the time there but the playing contents depend on the selected folder (on the basis of next and prev buttons)
Please help me in building this kind of player . . . Very Urgent for me
Your diagram is not complete. How are the button switches wired? Do you have a power supply connected somewhere?
Do you have code right now that can detect WHEN you press a switch,(not while the switch is pressed)? First things first:get the push buttons to be recognized by your program.
Push buttons are all grounded means a LOW to all the inputs as usual we do . .
power supply is as it is - Either from USB or line in socket in general nothing else . .
SD card module for UNO pattern is same as it has its MOSI MOSO CS SPK pins etc etc & too i mentioned that pin 9 - 13 is engaged with SD Card module and all that we all know . .
And no there is no code no support for now but somebody told me to use Array function but seriously i don't have any idea about that too . . .
#include <SD.h> // need to include the SD library
#define SD_ChipSelectPin 10 //connect pin 4 of arduino to cs pin of sd card
#include <TMRpcm.h> //Arduino library for asynchronous playback of PCM/WAV files
#include <SPI.h> // need to include the SPI library
#include<LiquidCrystal_I2C_Hangul.h>
//#include<Wire.h>
TMRpcm tmrpcm; // create an object for use in this sketch
int temp=1;
//int pp=0;
int prev=1;
int next=2;
void setup()
{
//pinMode(pp,INPUT_PULLUP);
pinMode(next,INPUT_PULLUP);
pinMode(prev,INPUT_PULLUP);
tmrpcm.speakerPin = 9; //5,6,11 or 46 on Mega, 9 on Uno, Nano, etc
Serial.begin(9600);
if (!SD.begin(SD_ChipSelectPin)) // returns 1 if the card is present
{
Serial.println("SD fail");
return;
}
tmrpcm.setVolume(5); //
tmrpcm.play("0.wav"); //the sound file "song" will play each time the arduino powers up, or is reset
//try to provide the file name with extension
}
void loop()
{
while(digitalRead(next)==0 || digitalRead(prev)==0)
{
//if(digitalRead(pp)==0)
//{
//tmrpcm.pause();
//while(digitalRead(pp)==0);
//delay(200);
//}
if(digitalRead(next)==0)
{
if(temp<4)//temp should be lesser than no. of songs
temp=temp+1;
while(digitalRead(next)==0);
delay(200);
song();
}
else if(digitalRead(prev)==0)
{
if(temp>1)
temp=temp-1;
while(digitalRead(prev)==0);
delay(200);
song();
}
}
}
void song (void)
{
if(temp==1)
{
tmrpcm.play("1.wav");
}
else if(temp==2)
{
tmrpcm.play("2.wav");
}
else if(temp==3)
{
tmrpcm.play("3.wav");
}
else if(temp==4)
{
tmrpcm.play("4.wav");
}
}
Above code is for Basic audio player available on you tube and scratch level projects what beginners do . . . This one is working fine and songs can be listed as per memory card capacity !!
The tmrpcm thing.
I helped another member work the bugs out of his implementation of that a couple of months or so ago. I don't know if he ever got the 'LM386' amplifier module going with it. The volume is super low from just a speaker though.
Yeah but that was failed to get designed and in that post, i got no help in that way . .
So i decided to cancel it out all the way so as to get with it's function a way ahead and after 3 months of paper work approx, finally reached at this point last week, so planned to start this fresh post with all of you, the experts . .
And that is the very reason to begin a separate, stand-alone program, just to test your switches and understand the logic you need to incorporate into the play program.
Sure, you can find a program that tests a switch. Perhaps the IDE sample programs? When that works, add the rest of your switches and test until you know how your program and switches operate together. Then you can decide what logic you want for your main program.
Just Wowww . . . i followed it and designed this code on the basis of example and here it is
#include <stdio.h>
#include <SD.h>
#include <SPI.h>
#include <TMRpcm.h>
#define SD_ChipSelectPin 10
TMRpcm tmrpcm;
// constants won't change. They're used here to set pin numbers:
const int buttonPin = 2; // the number of the pushbutton pin
const int ledPin = 5; // the number of the LED pin
// variables will change:
int buttonState = 0; // variable for reading the pushbutton status
void setup()
{
tmrpcm.speakerPin = (9);
//Serial.begin(9600);
if (!SD.begin(SD_ChipSelectPin))
{
Serial.println("SD fail");
return;
}
tmrpcm.setVolume(5);
tmrpcm.play("0.wav");
{
// initialize the LED pin as an output:
pinMode(ledPin, OUTPUT);
// initialize the pushbutton pin as an input:
pinMode(buttonPin, INPUT_PULLUP);
}
}
void loop() {
// read the state of the pushbutton value:
buttonState = digitalRead(buttonPin);
// check if the pushbutton is pressed. If it is, the buttonState is HIGH:
if (buttonState == LOW) {
// turn LED on:
digitalWrite(ledPin, HIGH);
tmrpcm.play("1.wav");
} else {
// turn LED off:
digitalWrite(ledPin, LOW);
}
}
A BIT ISSUE IS HERE - AS SOON AS THE SWITCH GETS PRESSED , THE LED TURNS ON BUT THE MOMENT I RELEASE THE SWITCH, LED TURNS OFF & THE SONG WAV FILE STARTS PLAYING ACTION . . .
IF I PRESS AND MAKE IT HOLD, THEN NO ACTION IS OBSERVED WITH THE SONG FILE THERE . . .
JUST PIN 5 LED TURNS ON AND KEEP GLOWING, UNTIL THE SWITCH GETS RELEASED , . . . SAY AN INVERSE OPTION
WELL, WORKING ON IT
PLEASE CHECK THE CODE AND HELP ME AHEAD . . .THANKS A TONNE FOR HELP !!