document.write('
Data hosted with ♥ by Pastebin.com - Download Raw - See Original
  1. // Eine Melodie mit dem Piepser abspielen
  2.  
  3. // ACHTUNG: Die Bibliothek PRO-BOT128_Lib_V2.cc ändern!
  4. /*
  5. void BEEP(word Tone, word Periode)
  6. {
  7.     Timer_T0FRQ(Tone,PS_64);
  8.     DELAY_MS(Periode);
  9.     //Timer_T0Stop();
  10.     Timer_Disable(0);
  11. }
  12. */
  13.  
  14. // Symbolische Konstanten definieren
  15.  
  16. #define C1 210
  17. #define D1 190
  18. #define E1 165
  19. #define F1 155
  20. #define G1 135
  21. #define A1 120
  22.  
  23. // Notenlängen definieren
  24. #define A 200      // Achtelnoten
  25. #define V 400      // Viertelnoten
  26. #define H 800      // Halbe Noten
  27. #define PAUSE 50   // Kurze Pause zwischen den Tönen
  28.  
  29. #define ANZAHL 11  // Anzahl der Noten im Song
  30.  
  31.  
  32. void main(void)
  33. {
  34.       PRO_BOT128_INIT();
  35.       LCD_Init();
  36.       DELAY_MS(100);
  37.  
  38.       // Platz für eigene Programmteile, die einmalig ausgeführt werden:
  39.       // Begrüßung
  40.       LCD_Locate(1,1);
  41.       LCD_WriteText("Beeper-Programm");
  42.  
  43.       // Lass es piepen
  44.       // ARRAY mit Noten definieren:
  45.  
  46.       int Noten[ANZAHL]= {C1, D1, E1, F1, G1, G1, A1, A1, A1, A1, G1};
  47.       int Laenge[ANZAHL]={A,  A,  A,  A,  V,  V,  A,  A,  A,  A,  H};
  48.  
  49.         // Endlos-Schleife
  50.             do
  51.             {
  52.                if (SW2!=0)
  53.                   {
  54.                   int i; // Notenzähler
  55.                   for(i=0; i<ANZAHL; i++)
  56.                     {
  57.                         BEEP(Noten[i], Laenge[i]);
  58.                         DELAY_MS(PAUSE);
  59.                     }
  60.                   SW2=0;
  61.                   }
  62.             }
  63.             while(1);
  64. }
');