Go Down

Topic: MP3 partially works with Arduino Uno (Read 1 time) previous topic - next topic

Cmjb13

Hello,

Purchased this mp3 card to connect to my arduino uno
MP3 card

Connected as following

Arduino TX to MP3 Pin 15 (RXD)
Arduino GND to MP3 Pin 19 (GND)
Arduino VIN to MP3 Pin 20 (VDD)

Audio cable Right to MP3 Pin 17 (HPR)
Audio cable Left to MP3 Pin 18 (HPL)
Audio cable Ground to MP3 Pin 19 (GND)

The program runs and sound is coming out of the speakers. However, sometimes when I hit upload the sound plays and sometimes it doesn't. Doesn't appear to be loose wires. Any ideas?

Code below
Code: [Select]

/*
Stepper Motor Control - one revolution
 
This program drives a unipolar or bipolar stepper motor.
The motor is attached to digital pins 8 - 11 of the Arduino.
 
The motor should revolve one revolution in one direction, then
one revolution in the other direction.
 
 
Created 11 Mar. 2007
Modified 30 Nov. 2009
by Tom Igoe
 
*/
 
#include <Stepper.h>
int x = 0;
const int stepsPerRevolution = 200;  // change this to fit the number of steps per revolution
// for your motor
 
// initialize the stepper library on pins 8 through 11:
Stepper myStepper(stepsPerRevolution, 8, 9, 10, 11);
 
void setup() {
  // set the speed at 60 rpm:
  myStepper.setSpeed(63);
  // initialize the serial port:
}
 
void loop() {
if (x <= 15)
{ // step one revolution in one direction:
  Serial.println("clockwise");
  myStepper.step(stepsPerRevolution);
  // delay(500);
x++;
}
  // step one revolution in the other direction:
  // Serial.println("counterclockwise");
// myStepper.step(-stepsPerRevolution);
// delay(500);
  Serial.write(0x01);
}

Grumpy_Mike

Quote
Any ideas?
It would be good if you actually posted the code you were having trouble in place of that random piece of code.

Cmjb13

That is the working code. Spins motor for 15 seconds and also plays the MP3 file.

uxomm

#3
Dec 13, 2015, 03:50 am Last Edit: Dec 13, 2015, 03:50 am by uxomm
Maybe a
Code: [Select]
Serial.begin(4800);
in setup might help. Right after
Code: [Select]
// initialize the serial port:
 :)
Always decouple electronic circuitry.

Grumpy_Mike

That is the working code. Spins motor for 15 seconds and also plays the MP3 file.
Why?
When doing a project work on one bit at a time. There is no attempt at communicating with your module in that code, it looks like you just copied some one else's code to pretend you had actually done some work. That is dishonest.

So start with the example code of how to drive your module and get that working first before adding layers of complications to it.

Cmjb13

Maybe a
Code: [Select]
Serial.begin(4800);
in setup might help. Right after
Code: [Select]
// initialize the serial port:
 :)
I originally had it there, but it would only play the first three seconds of the MP3 and constantly repeat.

Taking it out plays the full MP3 uninterrupted.

Cmjb13

Why?
When doing a project work on one bit at a time. There is no attempt at communicating with your module in that code, it looks like you just copied some one else's code to pretend you had actually done some work. That is dishonest.

So start with the example code of how to drive your module and get that working first before adding layers of complications to it.
My apologies, but I never intended to pass this off as my own code. Phrased better, I used a sample sketch and tweaked it to get it to what I needed it to do.

Grumpy_Mike

So that is what you should have posted, so we could see where you were going wrong. From your new description of the fault it sounds like you are triggering a sound when the button is pressed not when it becomes pressed. We can not fault find on code we can not see.

Cmjb13

I posted the code already in this thread. Maybe for some reason, you cannot see it.
Note that there is no button. The problem is when I upload the sketch sometimes the mp3 plays and sometimes it doesn't.

/*
Stepper Motor Control - one revolution
 
This program drives a unipolar or bipolar stepper motor.
The motor is attached to digital pins 8 - 11 of the Arduino.
 
The motor should revolve one revolution in one direction, then
one revolution in the other direction.
 
 
Created 11 Mar. 2007
Modified 30 Nov. 2009
by Tom Igoe
 
*/
 
#include <Stepper.h>
int x = 0;
const int stepsPerRevolution = 200;  // change this to fit the number of steps per revolution
// for your motor
 
// initialize the stepper library on pins 8 through 11:
Stepper myStepper(stepsPerRevolution, 8, 9, 10, 11);
 
void setup() {
  // set the speed at 60 rpm:
  myStepper.setSpeed(63);
  // initialize the serial port:
}
 
void loop() {
if (x <= 15)
{ // step one revolution in one direction:
  Serial.println("clockwise");
  myStepper.step(stepsPerRevolution);
  // delay(500);
x++;
}
  // step one revolution in the other direction:
  // Serial.println("counterclockwise");
// myStepper.step(-stepsPerRevolution);
// delay(500);
  Serial.write(0x01);
}

Grumpy_Mike

Quote
I posted the code already in this thread.
No you have not. You have posted nothing that addresses the MP3 player. You posted some code that attempts to control a motor and you have miss copied that too.

If you think you have posted any relevant code then we are all wasting our time.

You have already been told about the missing Serial.begin but you refuse to put it in.

You have done nothing about loading software serial and nothing about trying to write to the MP3 player. So stop pretending that the code you posted is, in any way trying to address your problem.

Please read this:-
How to use this forum It tells you how to ask a question.

Then maybe we can begin to address your problem.

Go Up