Need help! How to display music that is being played on the 1602 lcd?

Hello all!

I’m making an automatic school bell project with a few buttons and inserting an mp3 player in it.
The problem I am facing is, I have not found a way to display the song currently playing on the 1602 LCD that is used.

Please help for the problem I’m facing. Previously I say many thanks for the advice and problem solving that will be given.

This is the sketch program that I use.

//***************************************

#include <SoftwareSerial.h>
#include <DFPlayer_Mini_Mp3.h>
#include <Wire.h>
#include <LCD.h>
#include <LiquidCrystal_I2C.h>
#include <Time.h>
#include <TimeAlarms.h>
// #include <DS1307RTC.h>
#include “RTClib.h”

SoftwareSerial mySerial(10, 11);

#define I2C_ADDR 0x3F // <<----- Add your address here. Find it from I2C Scanner
#define BACKLIGHT_PIN 3
#define En_pin 2
#define Rw_pin 1
#define Rs_pin 0
#define D4_pin 4
#define D5_pin 5
#define D6_pin 6
#define D7_pin 7
LiquidCrystal_I2C lcd(I2C_ADDR,En_pin,Rw_pin,Rs_pin,D4_pin,D5_pin,D6_pin,D7_pin);

//***********************************************************************************************************

define Start_Byte 0x7E

define Version_Byte 0xFF

define Command_Length 0x06

define End_Byte 0xEF

define Acknowledge 0x00 //Returns info with command 0x41 [0x01: info, 0x00: no info]

define ACTIVATED LOW

int buttonNext = 12;
int buttonPause = 9;
int buttonPrevious = 8;
boolean isPlaying = false;

RTC_DS1307 RTC;
int hur[2], minu[2], secon[2];
char daysOfTheWeek[7][12] = {“SUN”, “MON”, “TUE”, “WED”, “THU”, “FRI”, “SAT”};
boolean blink = false;

const int button1 = 2;
const int button2 = 3;
const int button3 = 4;
const int button4 = 5;
const int button5 = 6;
const int button6 = 7;

void setup () {

pinMode(buttonPause, INPUT);
digitalWrite(buttonPause,HIGH);
pinMode(buttonNext, INPUT);
digitalWrite(buttonNext,HIGH);
pinMode(buttonPrevious, INPUT);
digitalWrite(buttonPrevious,HIGH);

pinMode(button1, INPUT);
pinMode(button2, INPUT);
pinMode(button3, INPUT);
pinMode(button4, INPUT);
pinMode(button5, INPUT);
pinMode(button6, INPUT);

digitalWrite(button1, 1);
digitalWrite(button2, 1);
digitalWrite(button3, 1);
digitalWrite(button4, 1);
digitalWrite(button5, 1);
digitalWrite(button6, 1);

Serial.begin (9600);
mySerial.begin (9600);
mp3_set_serial (mySerial);
mp3_set_volume (30);

//**********************************************
//playFirst();
isPlaying = true;

RTC_DS1307 RTC;
Wire.begin();
RTC.begin();

if
(! RTC.isrunning()) {
Serial.println(“RTC is NOT running!”);
// following line sets the RTC to the date & time this sketch was compirelay
// RTC.adjust(DateTime(DATE, TIME));
}

lcd.begin(16,2);
lcd.setBacklightPin(BACKLIGHT_PIN,POSITIVE);
lcd.setBacklight(HIGH);
lcd.home ();
lcd.clear();
delay(500);
}

void loop () {

DateTime now = RTC.now();
setTime(now.hour(), now.minute(), now.second(), now.day(), now.month(), now.year()); // set time & date
Alarm.delay(1000); //clock display delay
lcd.setCursor(0, 0);
lcd.print(daysOfTheWeek[now.dayOfTheWeek()]);
lcd.print(",");
lcd.print(now.day(), DEC);
lcd.write(’/’);
lcd.print(now.month(), DEC);
lcd.write(’/’);
lcd.print(now.year(), DEC);
lcd.write(’ ‘);
lcd.setCursor(0, 1);
lcd.print("TIME : ");
lcd.setCursor(7, 1);
Serial.print(now.hour(), DEC);
lcd.print(now.hour(), DEC);
Serial.print(’:’);
lcd.write(’:’);
Serial.print(now.minute(), DEC);
lcd.print(now.minute(), DEC);
lcd.write(’:’);
Serial.print(’:’);
lcd.print(now.second(), DEC);
lcd.write(" ");
Serial.print(now.second(), DEC);
Serial.println();

if (digitalRead(button1) == 0)
{
mp3_play (3);
lcd.clear();
lcd.setCursor(0,0);
lcd.print(“GOING TO CLASS”);
// delay(5000);
}

if (digitalRead(button2) == 0)
{
mp3_play (4);
lcd.clear();
lcd.setCursor(0,0);
lcd.print(“LESSON REPLACEMENT”);
// delay(5000);
}

if (digitalRead(button3) == 0)
{
mp3_play (5);
lcd.clear();
lcd.setCursor(0,0);
lcd.print(“BREAK”);
// delay(5000);
}

if (digitalRead(button4) == 0)
{
mp3_play (6);
lcd.clear();
lcd.setCursor(0,0);
lcd.print(“PRAYER TIME”);
// delay(5000);
}

if (digitalRead(button5) == 0)
{
mp3_play (7);
lcd.clear();
lcd.setCursor(0,0);
lcd.print(“GO HOME”);
// delay(5000);
}

if (digitalRead(button6) == 0)
{
mp3_stop ();
lcd.clear();
lcd.setCursor(0,0);
lcd.print(“STOP”);
// delay(5000);
}

//************* MP3 PLAYER **********************************************
//In this section I have not found a way to display music that is currently playing.

if (digitalRead(buttonPause) == ACTIVATED)
{
if(isPlaying)
{
pause();
isPlaying = false;
}else
{
isPlaying = true;
play();
}
}

if (digitalRead(buttonNext) == ACTIVATED)
{
if(isPlaying)
{
playNext();
}
}

if (digitalRead(buttonPrevious) == ACTIVATED)
{
if(isPlaying)
{
playPrevious();
}
}
}

void playFirst()
{
execute_CMD(0x3F, 0, 0);
delay(500);
setVolume(20);
delay(500);
execute_CMD(0x11,0,1);
delay(500);
}

void pause()
{
execute_CMD(0x0E,0,0);
delay(500);
lcd.clear();
lcd.setCursor(0,0);
lcd.print(“Pause”);
}

void play()
{
execute_CMD(0x0D,0,1);
lcd.clear();
lcd.setCursor(0,0);
lcd.print(“Play”);
delay(500);
}

void playNext()
{
execute_CMD(0x01,0,1);
lcd.clear();
lcd.setCursor(0,0);
lcd.print(“Play Next”);
delay(500);
}

void playPrevious()
{
execute_CMD(0x02,0,1);
lcd.clear();
lcd.setCursor(0,0);
lcd.print(“Play Previous”);
delay(500);
}

void setVolume(int volume)
{
execute_CMD(0x06, 0, volume); // Set the volume (0x00~0x30)
delay(2000);
}

void execute_CMD(byte CMD, byte Par1, byte Par2)
// Excecute the command and parameters
{
// Calculate the checksum (2 bytes)
word checksum = -(Version_Byte + Command_Length + CMD + Acknowledge + Par1 + Par2);
// Build the command line
byte Command_line[10] = { Start_Byte, Version_Byte, Command_Length, CMD, Acknowledge,
Par1, Par2, highByte(checksum), lowByte(checksum), End_Byte};
//Send the command line to the module
for (byte k=0; k<10; k++)
{
mySerial.write( Command_line[k]);
}
}

BEL_AUTOMATIC_SCHOOL.ino (5.94 KB)

Does your Arduino know the name of the song? If so, you can display it.

Paul

What MP3 player are you using? A datasheet/operating manual for it would be useful. Does it have a command that tells you the name of song playing? Or a command that tells you what file it's playing? Or anything useful?

If not then all you have is all those assorted playXXXX commands. So you'll have to use a variable to keep track of what the number of the song playing is and match that to a list of song names that you maintain within the program then display the name. Good luck!

Steve

You SHOULD define the list of the song's names in an array. The order is the same as the order in MP3 Player. Each time you send the command to play next, you SHOULD increase the current index in the array by one. You can get the song name in the array using the current index.

For displaying on LCD, you can refer to this tutorial