Donc je faisait la mélodie pour mon buzzer et Arduino me dit de redéfinir " int melody [] ".....Quelqu'un peut me dire quoi faire?
#include "pitches.h"
#define melodyPin 12
#define bpm 140
#define noteGapPercentage 10
int melody [] = {
NOTE_C4, NOTE_C4, NOTE_C5, NOTE_C5,
NOTE_AS4, NOTE_A4, NOTE_G4, NOTE_F4,
NOTE_C4, NOTE_C4, NOTE_C4, NOTE_G4,
NOTE_F4, NOTE_G4, NOTE_F4, NOTE_E4,
NOTE_C4, NOTE_D4, NOTE_D5, NOTE_D5,
NOTE_C5, NOTE_AS4, NOTE_A4, NOTE_G4,
NOTE_E5, NOTE_D5, NOTE_C5, NOTE_C5,
NOTE_AS4, NOTE_A4, NOTE_G4, NOTE_F4
} ;
int noteDurations[] = {
4 , 4 , 4 , 4 ,
4 , 4 , 4 , 4 ,
2 , 4 , 4 , 4 ,
4 , 4 , 4 , 4 ,
2 , 4 , 4 , 4 ,
4 , 4 , 4 , 2 ,
4 , 4 , 4 , 4 ,
4 , 4 , 4 , 4
} ;
#define beatDuration ( 60,0 / bpm ) * 1000000L
#define noteGap beatDuration * (noteGapPercentage / 100.0)
void setup() {
pinMode(speakerPin, OUTPUT);
for (int thisNote = 0; thisNote < 8; thisNote++) {
// to calculate the note duration, take one second divided by the note type.
//e.g. quarter note = 1000 / 4, eighth note = 1000/8, etc.
int noteDuration = 1000 / noteDurations[thisNote];
tone(8, melody[thisNote], noteDuration);
// to distinguish the notes, set a minimum time between them.
// the note's duration + 30% seems to work well:
int pauseBetweenNotes = noteDuration * 1.30;
delay(pauseBetweenNotes);
// stop the tone playing:
noTone(8);
}
}
void loop() {
// no need to repeat the melody.