Cytron Shield MP3 Library Issues

Talk about Arduino board, sheilds. Sharing Arduino projects, program, problems, solutions, suggestions..... many more, all are welcome.

Cytron Shield MP3 Library Issues

Postby eechaye » Mon Aug 31, 2015 9:56 pm

Hi Mr/Mrs,

I had bought a cytron mp3 shield and attach it on Arduino Mega 2560 for testing, I also had download its libraries on http://tutorial.cytron.com.my/2015/07/3 ... w-library/ and copy MP3Player & SdFat file to Arduino IDE library as the link instructed.

My main problem is that the MP3Player and SdFat file declaration cannot be detected on my Arduino IDE,

CODE: SELECT_ALL_CODE
#include <LiquidCrystal.h>
#include <MP3Player.h>

//Declare Pin Name
MP3Player playerone(3, 2); 
LiquidCrystal lcd(8, 9, 4, 5, 6, 7);
const int analogInPin = A7;
const int RedLed = 25;
const int GreenLed = 33;
const int BlueLed = 29;
const int buttonPin = 49;
const int RGBdelay = 200;
int buttonState = 0;
int sensorValue = 0;
int sensorValueRed = 0;
int sensorValueGreen = 0;
int sensorValueBlue = 0;

void setup()
{
  playerone.Init();
  playerone.Volume(240);
  Serial.begin(9600);
  lcd.begin(16, 2);

  lcd.print("   WELCOME TO");
  lcd.setCursor(0, 1);
  lcd.print("Colour  Detector");
  delay(5000);

  pinMode(buttonPin, INPUT);
  pinMode(RedLed, OUTPUT);
  pinMode(GreenLed, OUTPUT);
  pinMode(BlueLed, OUTPUT);

  lcd.clear();
  lcd.setCursor(0, 0);
  lcd.print("   START SCAN");
  delay(2000);
}

void loop()
{
  buttonState = digitalRead(buttonPin);
  if (buttonState == LOW)
  {
    lcd.print("SCAN NOW----------");
    delay(200);
    digitalWrite(RedLed, 1);
    digitalWrite(GreenLed, 1);
    digitalWrite(BlueLed, 1);
  }
  else
  {
    digitalWrite(RedLed, 0);
    delay(20);
    sensorValueRed = analogRead(analogInPin) / 10 ;
    delay(RGBdelay);
    digitalWrite(RedLed, 1);

    digitalWrite(GreenLed, 0);
    delay(20);
    sensorValueGreen = analogRead(analogInPin) / 10;
    delay(RGBdelay);
    digitalWrite(GreenLed, 1);

    digitalWrite(BlueLed, 0);
    delay(20);
    sensorValueBlue = analogRead(analogInPin) / 10 ;
    delay(RGBdelay);
    digitalWrite(BlueLed, 1);     //*************************************************************************************

    //Display sensor value

    lcd.setCursor(0, 0);
    lcd.print("R:    G:    B:  ");
    lcd.setCursor(2, 0);
    lcd.print(sensorValueRed);
    lcd.print(" ");
    lcd.setCursor(8, 0);
    lcd.print(sensorValueGreen);
    lcd.print(" ");
    lcd.setCursor(14, 0);
    lcd.print(sensorValueBlue);
    lcd.print(" ");

    //detect colour
    if ((sensorValueRed >= 0 && sensorValueRed <= 47) && (sensorValueGreen >= 10 && sensorValueGreen <= 44) && (sensorValueBlue >= 12 && sensorValueBlue <= 55))
    {
      lcd.setCursor(0, 1);
      lcd.print("--COLOUR=BLACK--");
      playerone.Play("black.mp3");
    }

    else if ((sensorValueRed >= 7 && sensorValueRed <= 60) && (sensorValueGreen >= 33 && sensorValueGreen <= 54) && (sensorValueBlue >= 57 && sensorValueBlue <= 76))
    {
      lcd.setCursor(0, 1);
      lcd.print("--COLOUR=BLUE---");
      playerone.Play("blue.mp3");
    }

    else if ((sensorValueRed >= 57 && sensorValueRed <= 82) && (sensorValueGreen >= 45 && sensorValueGreen <= 64) && (sensorValueBlue >= 24 && sensorValueBlue <= 59))
    {
      lcd.setCursor(0, 1);
      lcd.print("---COLOUR=RED---");
      playerone.Play("red.mp3");
    }

    else if ((sensorValueRed >= 47 && sensorValueRed <= 83) && (sensorValueGreen >= 55 && sensorValueGreen <= 65) && (sensorValueBlue >= 64 && sensorValueBlue <= 72))
    {
      lcd.setCursor(0, 1);
      lcd.print("-COLOUR=MAGENTA-");
      playerone.Play("magenta.mp3");
    }

    else if ((sensorValueRed >= 5 && sensorValueRed <= 59) && (sensorValueGreen >= 44 && sensorValueGreen <= 67) && (sensorValueBlue >= 44 && sensorValueBlue <= 66))
    {
      lcd.setCursor(0, 1);
      lcd.print("--COLOUR=GREEN--");
      playerone.Play("green.mp3");
    }

    else if ((sensorValueRed >= 30 && sensorValueRed <= 59) && (sensorValueGreen >= 57 && sensorValueGreen <= 70) && (sensorValueBlue >= 70 && sensorValueBlue <= 80))
    {
      lcd.setCursor(0, 1);
      lcd.print("--COLOUR=CYAN---");
      playerone.Play("cyan.mp3");
    }

    else if ((sensorValueRed >= 63 && sensorValueRed <= 84) && (sensorValueGreen >= 67 && sensorValueGreen <= 78) && (sensorValueBlue >= 48 && sensorValueBlue <= 68))
    {
      lcd.setCursor(0, 1);
      lcd.print("--COLOUR=YELLOW-");
      playerone.Play("yellow.mp3");
    }

    else if ((sensorValueRed >= 68 && sensorValueRed <= 84) && (sensorValueGreen >= 70 && sensorValueGreen <= 78) && (sensorValueBlue >= 72 && sensorValueBlue <= 84))
    {
      lcd.setCursor(0, 1);
      lcd.print("--COLOUR=WHITE--");
      playerone.Play("white.mp3");
    }

    else
    {
      lcd.setCursor(0, 1);
      lcd.print("-UNKNOWN COLOUR-");
    }
    delay(1000);
  }
}


Here are the error message:
In file included from colour_detector_code.ino:2:
C:\Users\IETAN\Desktop\EE Apps\arduino-1.0.4-windows\arduino-1.0.4\libraries\MP3Player/MP3Player.h:43: error: 'SdFat' does not name a type
C:\Users\IETAN\Desktop\EE Apps\arduino-1.0.4-windows\arduino-1.0.4\libraries\MP3Player/MP3Player.h:44: error: 'SdFile' does not name a type
colour_detector_code:5: error: no matching function for call to 'MP3Player::MP3Player(int, int)'
C:\Users\IETAN\Desktop\EE Apps\arduino-1.0.4-windows\arduino-1.0.4\libraries\MP3Player/MP3Player.h:47: note: candidates are: MP3Player::MP3Player()
C:\Users\IETAN\Desktop\EE Apps\arduino-1.0.4-windows\arduino-1.0.4\libraries\MP3Player/MP3Player.h:47: note: MP3Player::MP3Player(const MP3Player&)
colour_detector_code.ino: In function 'void setup()':
colour_detector_code:21: error: no matching function for call to 'MP3Player::Init()'
C:\Users\IETAN\Desktop\EE Apps\arduino-1.0.4-windows\arduino-1.0.4\libraries\MP3Player/MP3Player.h:50: note: candidates are: boolean MP3Player::Init(byte, byte)
colour_detector_code:22: error: 'class MP3Player' has no member named 'Volume'
C:\Users\IETAN\Desktop\EE Apps\arduino-1.0.4-windows\arduino-1.0.4\libraries\MP3Player/MP3Player.h: In function 'void loop()':
C:\Users\IETAN\Desktop\EE Apps\arduino-1.0.4-windows\arduino-1.0.4\libraries\MP3Player/MP3Player.h:104: error: 'boolean MP3Player::Play(const char*)' is private
colour_detector_code:92: error: within this context
C:\Users\IETAN\Desktop\EE Apps\arduino-1.0.4-windows\arduino-1.0.4\libraries\MP3Player/MP3Player.h:104: error: 'boolean MP3Player::Play(const char*)' is private
colour_detector_code:99: error: within this context
C:\Users\IETAN\Desktop\EE Apps\arduino-1.0.4-windows\arduino-1.0.4\libraries\MP3Player/MP3Player.h:104: error: 'boolean MP3Player::Play(const char*)' is private
colour_detector_code:106: error: within this context
C:\Users\IETAN\Desktop\EE Apps\arduino-1.0.4-windows\arduino-1.0.4\libraries\MP3Player/MP3Player.h:104: error: 'boolean MP3Player::Play(const char*)' is private
colour_detector_code:113: error: within this context
C:\Users\IETAN\Desktop\EE Apps\arduino-1.0.4-windows\arduino-1.0.4\libraries\MP3Player/MP3Player.h:104: error: 'boolean MP3Player::Play(const char*)' is private
colour_detector_code:120: error: within this context
C:\Users\IETAN\Desktop\EE Apps\arduino-1.0.4-windows\arduino-1.0.4\libraries\MP3Player/MP3Player.h:104: error: 'boolean MP3Player::Play(const char*)' is private
colour_detector_code:127: error: within this context
C:\Users\IETAN\Desktop\EE Apps\arduino-1.0.4-windows\arduino-1.0.4\libraries\MP3Player/MP3Player.h:104: error: 'boolean MP3Player::Play(const char*)' is private
colour_detector_code:134: error: within this context
C:\Users\IETAN\Desktop\EE Apps\arduino-1.0.4-windows\arduino-1.0.4\libraries\MP3Player/MP3Player.h:104: error: 'boolean MP3Player::Play(const char*)' is private
colour_detector_code:141: error: within this context



Thanks

________
EeChaye
Attachments
MP3Player and SdFat declaration error.png
The MP3Player and SdFat Library Undetected
eechaye
Greenhorn
 
Posts: 2
Joined: Mon Aug 31, 2015 9:08 pm

Re: Cytron Shield MP3 Library Issues

Postby bengchet » Tue Sep 01, 2015 10:13 am

Hi eechaye,

Thank you for purchasing Cytron MP3 shield.

So far you have done correctly for installation of MP3Player and SdFat library. But I noticed that your program is written based on old MP3Player library. Few modifications are needed to be done.

1. Add #include <SdFat.h> line at the beginning of the program
2. Functionalities such as MP3Player playerone(3,2), playerone.Init(), playerone.Volume(240), etc do not exist in the new MP3Player library you have installed. You can modify these functionalities according to the Included functionalities table in the tutorial http://tutorial.cytron.com.my/2015/07/30/cytron-mp3-shield-with-new-library/

For example:
-> remove MP3Player playerone(3,2) because this function doesn't exist
-> change playerone.Init() to mp3.Init(3,2)
-> change playerone.Volume(240) to mp3.setVolume(240)
-> change playerone.Play("xxx.mp3") to mp3.PlayTrack("xxx.mp3")
and the rest ...

Do follow the instructions step by step starting from Let's give it a test! category in the tutorial stated because these steps guide you to setup MP3 shield and execute some program testing to see if the whole thing is hooked up correctly. If it is working, you can try few another example sketches such as LCDMP3Player as I can see you are using LCD/LCDshield as well. Then you can try develop your program from these sketches.

Thanks and cheers! :D
bengchet
Moderator
 
Posts: 237
Joined: Tue Aug 25, 2015 8:29 am

Re: Cytron Shield MP3 Library Issues

Postby eechaye » Tue Sep 01, 2015 6:41 pm

Hi BengChet

It's work. really appreciates your help. This coding did not work on my previous Arduino 1.0.4 version but work on newest Arduino 1.6.5 version.

Thank you...

_________
EeChaye
eechaye
Greenhorn
 
Posts: 2
Joined: Mon Aug 31, 2015 9:08 pm


Return to Arduino Based

Who is online

Users browsing this forum: No registered users and 7 guests