Advertisement
nikonn

PRO-BOT-Beeper var. 1

Dec 11th, 2014
418
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 1.61 KB | None | 0 0
  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. // Noten
  16. #define C 210
  17. #define D 190
  18. #define E 165
  19. #define F 155
  20. #define G 135
  21. #define H 120
  22. // Notenlängen
  23. #define ACHTEL 200
  24. #define VIERTEL 400
  25. #define HALBE 800
  26. #define PAUSE 50
  27.  
  28.  
  29. void main(void)
  30. {
  31.       PRO_BOT128_INIT();
  32.       LCD_Init();
  33.       DELAY_MS(100);
  34.  
  35.       // Platz für eigene Programmteile, die einmalig ausgeführt werden:
  36.       // Begrüßung
  37.       LCD_Locate(1,1);
  38.       LCD_WriteText("Beeper-Programm");
  39.  
  40.       // Hier piept's wohl:
  41.       BEEP(C, ACHTEL);
  42.       DELAY_MS(PAUSE);
  43.       BEEP(D, ACHTEL);
  44.       DELAY_MS(PAUSE);
  45.       BEEP(E, ACHTEL);
  46.       DELAY_MS(PAUSE);
  47.       BEEP(F, ACHTEL);
  48.       DELAY_MS(PAUSE);
  49.       BEEP(G, VIERTEL);
  50.       DELAY_MS(PAUSE);
  51.       BEEP(G, VIERTEL);
  52.       DELAY_MS(PAUSE);
  53.       BEEP(H, ACHTEL);
  54.       DELAY_MS(PAUSE);
  55.       BEEP(H, ACHTEL);
  56.       DELAY_MS(PAUSE);
  57.       BEEP(H, ACHTEL);
  58.       DELAY_MS(PAUSE);
  59.       BEEP(H, ACHTEL);
  60.       DELAY_MS(PAUSE);
  61.       BEEP(G, HALBE);
  62.       DELAY_MS(PAUSE);
  63.       BEEP(H, ACHTEL);
  64.       DELAY_MS(PAUSE);
  65.       BEEP(H, ACHTEL);
  66.       DELAY_MS(PAUSE);
  67.       BEEP(H, ACHTEL);
  68.       DELAY_MS(PAUSE);
  69.       BEEP(H, ACHTEL);
  70.       DELAY_MS(PAUSE);
  71.       BEEP(G, HALBE);
  72.       DELAY_MS(PAUSE);
  73.  
  74.  
  75.  
  76.         // Endlos-Schleife
  77.             do
  78.             {
  79.  
  80.             }
  81.             while(1);
  82. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement