//This C# program is based on Arduino sketch to generate tone http://arduino.cc/en/Tutorial/Tone //The sketch available here: http://arduino.cc/en/Tutorial/Tone was in public domain at the time of writing this program. //This program is free for all for any purpose. To use the program you have to agree to following disclaimer // ******************************************** // DISCLAIMER: The author of this C# program can in no way be held responsible for any damage that is // caused directly or indirectly to your PC , arduino board or any other hardware or software by the use of this program. // Use the program at your own risk. //********************************************* using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace MelodyTester { class Program { static void Main(string[] args) { int NOTE_C3 = 131; int NOTE_CS3 = 139; int NOTE_D3 = 147; int NOTE_DS3 = 156; int NOTE_E3 = 165; int NOTE_F3 = 175; int NOTE_FS3 = 185; int NOTE_G3 = 196; int NOTE_GS3 = 208; int NOTE_A3 = 220; int NOTE_AS3 = 233; int NOTE_B3 = 247; int NOTE_C4 = 262; int NOTE_CS4 = 277; int NOTE_D4 = 294; int NOTE_DS4 = 311; int NOTE_E4 = 330; int NOTE_F4 = 349; int NOTE_FS4 = 370; int NOTE_G4 = 392; int NOTE_GS4 = 415; int NOTE_A4 = 440; int NOTE_AS4 = 466; int NOTE_B4 = 494; int NOTE_C5 = 523; int NOTE_CS5 = 554; // PAUSE = 0 //Play the following notes //cdf dfg fga gab abc# int[] melody = new int[] { NOTE_C4,0,NOTE_D4,0,NOTE_F4,0, NOTE_D4,0,NOTE_F4,0,NOTE_G4,0, NOTE_F4,0,NOTE_G4,0, NOTE_A4,0, NOTE_G4,0,NOTE_A4,0, NOTE_B4,0, NOTE_A4,0,NOTE_B4,0, NOTE_C5,0}; int[] noteDurations = new int[] { 8,8,8,8,8,4, 8,8,8,8,8,4, 8,8,8,8,8,4, 8,8,8,8,8,4, 8,8,8,8,8,4}; for (int thisNote = 0; thisNote < 30; thisNote++) { int noteDuration = 1000 / noteDurations[thisNote]; if (melody[thisNote] > 0) Console.Beep(melody[thisNote], noteDuration); else System.Threading.Thread.Sleep(noteDuration); } } } }