Hello, I am trying to play an audio (mp3) from a SD card on an Arduino Mega 2560 (speaker 8 ohm). I dont understand the warning it's giving me, I have tried everything. Here is the whole error: C:\Users\eleve\OneDrive\Documents\Arduino\speaker_code\sketch_jan26a\sketch_jan26a.ino: In function 'void setup()':
C:\Users\eleve\OneDrive\Documents\Arduino\speaker_code\sketch_jan26a\sketch_jan26a.ino:21:20: warning: ISO C++ forbids converting a string constant to 'char*' [-Wwrite-strings]
tmrpcm.play("1.wav");
error:
C:\Users\eleve\OneDrive\Documents\Arduino\speaker_code\sketch_jan26a\sketch_jan26a.ino: In function 'void setup()':
C:\Users\eleve\OneDrive\Documents\Arduino\speaker_code\sketch_jan26a\sketch_jan26a.ino:21:20: warning: ISO C++ forbids converting a string constant to 'char*' [-Wwrite-strings]
tmrpcm.play("1.wav");
C:\Users\eleve\OneDrive\Documents\Arduino\speaker_code\sketch_jan26a\sketch_jan26a.ino: In function 'void setup()':
C:\Users\eleve\OneDrive\Documents\Arduino\speaker_code\sketch_jan26a\sketch_jan26a.ino:21:20: warning: ISO C++ forbids converting a string constant to 'char*' [-Wwrite-strings]
tmrpcm.play("1.wav");
^
Le croquis utilise 12832 octets (5%) de l'espace de stockage de programmes. Le maximum est de 253952 octets.
Les variables globales utilisent 1458 octets (17%) de mémoire dynamique, ce qui laisse 6734 octets pour les variables locales. Le maximum est de 8192 octets.
could the problem be in the connection of the arduino and the speaker?
I connected from the SD card:
CS to 4
SCK to 13
MOSI to 11
MISO to 12
VCC to 5v
and both grn together
I guess: "1.wav" is a constant, a string sitting in memory (Read-Only).
But the .play() uses a "Read-Write" (not const) pointer, e.g. as
play(char *);
It is a warning to tell you as: "your play could modify (write) your string, but the string comes from R/O-memory (e.g. flash) and cannot be written".
Forwarding a const to a non-const is always a warning (or even a bug! a warning can be a bug!)