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