// //HENDRY. K
// //LAGU INDONESIA RAYA
// #define NOTE_C 261
// #define NOTE_D 294
// #define NOTE_E 329
// #define NOTE_F 349
// #define NOTE_G 392
// #define NOTE_A 440
// #define NOTE_B 493
// #define NOTE_C1 523
// #define BUZZER_PIN 11
// int melody[] = {
// NOTE_G, NOTE_E, NOTE_G, NOTE_E, NOTE_E, NOTE_F, NOTE_G, NOTE_F, NOTE_D,
// NOTE_F, NOTE_A, NOTE_G, NOTE_F, NOTE_E, NOTE_A, NOTE_F, NOTE_A, NOTE_F,
// NOTE_A, NOTE_B, NOTE_C1, NOTE_C1, NOTE_E, NOTE_G, NOTE_F, NOTE_D, NOTE_C
// };
// int durations[] = {
// 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 3,
// 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 3,
// 4, 4, 4, 4, 2, 4, 4, 4, 4, 2,
// 4, 4, 4, 4, 4, 4, 4, 3,
// 1, 2, 1,
// 4, 4, 4, 4, 4, 4, 4, 4, 4, 3,
// 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 3,
// 4, 4, 4, 3, 4, 4, 4, 4, 4, 3,
// 4, 3, 4, 3, 4, 4, 4, 4, 4, 3,
// 4, 4, 4, 3, 4, 4, 4, 4, 4, 3,
// 4, 4, 4, 4, 4, 3, 2, 1, 500
// };
// void setup() {
// pinMode(BUZZER_PIN, OUTPUT);
// }
// void loop() {
// int size = sizeof(durations) / sizeof(int);
// for (int note = 0; note < size; note++) {
// //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 duration = 1000 / durations[note];
// tone(BUZZER_PIN, melody[note], duration);
// //to distinguish the notes, set a minimum time between them.
// //the note's duration + 30% seems to work well:
// int pauseBetweenNotes = duration * 1.30;
// delay(pauseBetweenNotes);
// //stop the tone playing:
// noTone(BUZZER_PIN);
// }
// // for (int thisNote = 0; thisNote < sizeof(melody) / sizeof(int); thisNote++)
// // {
// // tone(11, melody[thisNote], noteDurations[thisNote] * .7);
// // delay(noteDurations[thisNote]);
// // noTone(11);
// // }
// }
// int speakerPin = 11;
// int length = 30;
// char notes[] = "gegeefgfdfagfeafafabCCegfdc ";
// int beats[] = { 1, 1, 1, 1, 1, 1, 2, 1, 1.4, 1, 1.8, 1, 1.5, 2.5, 1, 1.5, 1.5, 1, 1, 1, 1, 2.5, 1, 1, 1, 1, 1, 1, 1};
// int tempo = 280;
// void playTone(int tone, int duration) {
// for (long i = 0; i < duration * 1000L; i += tone * 2) {
// digitalWrite(speakerPin, HIGH);
// delayMicroseconds(tone);
// digitalWrite(speakerPin, LOW);
// delayMicroseconds(tone);
// }
// }
// void playNote(char note, int duration) {
// char names[] = { 'c', 'd', 'e', 'f', 'g', 'a', 'b', 'C' };
// int tones[] = { 1915, 1700, 1519, 1432, 1275, 1136, 1014, 956 };
// // play the tone corresponding to the note name
// for (int i = 0; i < 8; i++) {
// if (names[i] == note) {
// playTone(tones[i], duration);
// }
// }
// }
// void setup() {
// pinMode(speakerPin, OUTPUT);
// }
// void loop() {
// for (int i = 0; i < length; i++) {
// if (notes[i] == ' ') {
// delay(beats[i] * tempo); // rest
// } else {
// playNote(notes[i], beats[i] * tempo);
// }
// // pause between notes
// delay(tempo / 2);
// }
// }