Hello,
I’m new on Arduino. I have an Arduino UNO. Just after the Blink test, I was working on making music with my floppy disc.
Just to test the program, I wrote a long list of function call that are used to play a given tone for a given time.
8 #define _DIR 12
18 #define INV_DIR dir = (dir == HIGH ? LOW : HIGH); digitalWrite(_DIR, dir
...
81 void play(unsigned int duration, int step_delay) {
82 int time = millis();
83
84 while (millis() - time < duration) {
85 step(step_delay);
86 INV_DIR;
87 }
88 }
89
90 void step(int step_delay) {
91 delayMicroseconds(step_delay);
92 digitalWrite(MOTEB, LOW);
93 delayMicroseconds(step_delay);
94 digitalWrite(MOTEB, HIGH);
95 }
...
194 play(t/2, SI*2);
195 play(t*2.5, FA);
196 play(t*0.75, LA*2);
197 play(t*0.25, SI*2);
198
199 play(t, DO);
200 play(t, RE);
201 play(t, MI);
202 play(t*0.75, MI*2);
203 play(t*0.25, FA*2);
204
205 play(t/2, SO*2);
206 play(t*2.5, DO);
207 play(t*0.75, RE);
208 play(t*0.25, MI);
209
210 play(t*3, FA);
211 play(t*0.75, SO*2);
212 play(t*0.25, SO*2);
... And so one
I have no compilation probleme nor upload problems. But when I start the program, it work well but stops after a constant certain number of notes.
I first thought it was a problem within my code, but whatever i could write, the program will stop after the same number of play(…) function call.
It can’t be an out of memory issue since I don’t use more and more memory while playing.
I really do not know what is appening here. Could you help me ?
By the way: I am not slaughtering english language on purpose. I’m not english.
Thanks