Papermind

Simple tone

Mar 19th, 2018
6,751
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.55 KB | None | 0 0
  1. /*
  2. Simple tone
  3. created March 2018
  4. By Papermindvention.blogspot.com
  5. */
  6.  
  7. int pinbuzz = 3;
  8.     //array untuk menghasilkan nada yang berbeda - beda
  9. int song[]= {500,1000,1500,2000,1500,1000,500};
  10.     //array untuk mengatur durasi
  11. int durasi[]= {80,180,280,380,500,1000,1500};
  12. void setup() {pinMode (pinbuzz, OUTPUT);}
  13. void loop() {
  14.   for (int note = 0; note <7; note ++){
  15. /* nyalakan buzzer dengan nada berurutan sesuai array (song), dengan durasinya sesuai dengan array (durasi)*/
  16.   tone(pinbuzz, song[note], durasi[note]);
  17.   delay(durasi[note]);
  18.   }
  19. }
Advertisement
Add Comment
Please, Sign In to add comment