I have a projekt, where I have an LCD-Display with a game. Then I liked to implement a melody, that comes if you win (With a Piezo). The Melody itself works, the game too, but both together not: The upload works and it seems to be all good, but the program does not start. There’s no error Message. I’v already tried writing a function at the beginning of the setup, but it happens nothing. I don’t know what I’ve done wrong, and try it since a whole week, but I’m sure it’s a mistake from the Arduino-Software, because both itsef worked fine. But I’m a really beginner, so sorry if it’s a bad mistake from me
The whole Code is in the attechment (I wrote the notices in German, because I am german ;D)
I think, everybody can believe me, if I say, the other things work fine alone
Thanks for your help,
Ardi.ino (13.6 KB)
pitches.h (1.78 KB)
Hi, welcome to the forum, willkommen im forum.
Are you using an Arduino Uno ?
Perhaps you are out of ram memory.
I don't have those lcd libraries, so I can't compile it.
You could put those tables into PROGMEM, or at least the melody and durations.
sizeof(melody) + sizeof(noteDurations) = 1536
That is too much for an Arduino Uno.
Use the new Arduino IDE 1.6.0, and ignore the outdated reference for PROGMEM ( http://arduino.cc/en/Reference/PROGMEM ).
This explains it : Gammon Forum : Electronics : Microprocessors : Putting constant data into program memory (PROGMEM)
I wrote code to make a melody in the background : http://forum.arduino.cc/index.php?topic=290598.msg2036210#msg2036210
but I'm sure it's a mistake from the Arduino-Software, because both itsef worked fine
That's a pretty poor assumption.
Two liters of beer will fit in a 3 liter stein. Once. Not twice.
It is a near certainty that you are running out of memory.
The values that you are storing in noteDurations do not require that the array type be int.
digits is pissing memory away uselessly.
Lots of ways of skinning this moggy.
Put "melody" and "noteDurations" into program memory.
Make "noteDurations" type "byte".
"pitches.h" contains 89 notes, each requiring an "int" to store it.
"melody" requires each element to be an "int" because you are storing the pitch values in the array.
Imagine instead of storing the note value, you stored an index into another array of the all the pitch values.
Now, "melody" only needs to be an array of "byte"s too, because no index exceeds about 90.
I’m sure it’s a mistake from the Arduino-Software, because both itsef worked fine.
If you can lift a 55kg fieldstone and carry it away, and you also can lift another fieldstone that weighs 60 kg, then it must be your own mistake, if you are unable to carry them both at the same time!
I’m sure, because carrying each of them alone worked fine!
How to use this forum
I added this:
Serial.println (sizeof melody);
Serial.println (sizeof noteDurations);
Serial.println (sizeof wordbyte);
Plus your 8 x byte arrays (Stern, Enemy etc.) which is another 64 bytes.
Total = 1620. If you have a Uno or similar you will almost be out of RAM (2048 bytes), even before adding the LCD display.
You could put your arrays into PROGMEM.
... but I'm sure it's a mistake from the Arduino-Software ...
Wenn der Reiter nichts taugt, hat das Pferd Schuld.