In this short tutorial explains the basics of operation of a piezoelectric terminal that will be driven by Arduino in order to play the popular tune of Super Mario Bros.
In this tutorial we will take confidence with a piezoelectric device, commonly called buzzer. Today we play for the tune of Super Mario Bros, dating back to the 80s.
The Buzzer
The buzzer is a piezoelectric circuit element capable of emitting sounds of different frequencies depending on the voltage that reaches him. To activate it, however, is necessary to produce a square wave, or a succession of high and low voltage logic.
Sketch
int buzzer = 3; void setup () {pinMode (3, OUTPUT);} void loop () {tone (buzzer, 660, 100), delay (150); tone (buzzer, 660, 100), delay (300) ; tone (buzzer, 660, 100), delay (300); tone (buzzer, 510, 100), delay (100); tone (buzzer, 660, 100), delay (300); tone (buzzer, 770, 100 ) delay (550); tone (buzzer, 380, 100), delay (575); tone (buzzer, 510, 100), delay (450); tone (buzzer, 380, 100), delay (400); tone (buzzer, 320, 100), delay (500); tone (buzzer, 440, 100), delay (300); tone (buzzer, 480, 80); delay (330); tone (buzzer, 450, 100); delay (150); tone (buzzer, 430, 100), delay (300); tone (buzzer, 380, 100), delay (200); tone (buzzer, 660, 80); delay (200); tone (buzzer , 760, 50), delay (150); tone (buzzer, 860, 100), delay (300); tone (buzzer, 700, 80); delay (150); tone (buzzer, 760, 50), delay ( 350), tone (buzzer, 660, 80); delay (300); tone (buzzer, 520, 80); delay (150); tone (buzzer, 580, 80); delay (150); tone (buzzer, 480 , 80), delay (500); tone (buzzer, 510, 100), delay (450); tone (buzzer, 380, 100), delay (400); tone (buzzer, 320, 100), delay (500) ; tone (buzzer, 440, 100), delay (300); tone (buzzer, 480, 80); delay (330); tone (buzzer, 450, 100), delay (150); tone (buzzer, 430, 100 ) delay (300); tone (buzzer, 380, 100), delay (200); tone (buzzer, 660, 80); delay (200); tone (buzzer, 760, 50), delay (150); tone (buzzer, 860, 100), delay (300); tone (buzzer, 700, 80); delay (150); tone (buzzer, 760, 50), delay (350); tone (buzzer, 660, 80); delay (300); tone (buzzer, 520, 80); delay (150); tone (buzzer, 580, 80); delay (150); tone (buzzer, 480, 80); delay (500); tone (buzzer , 500, 100), delay (300); tone (buzzer, 760, 100), delay (100); tone (buzzer, 720, 100), delay (150); tone (buzzer, 680, 100), delay ( 150), tone (buzzer, 620, 150), delay (300); tone (buzzer, 650, 150), delay (300); tone (buzzer, 380, 100), delay (150); tone (buzzer, 430 , 100), delay (150); tone (buzzer, 500, 100), delay (300); tone (buzzer, 430, 100), delay (150); tone (buzzer, 500, 100), delay (100) ; tone (buzzer, 570, 100), delay (220); tone (buzzer, 500, 100), delay (300); tone (buzzer, 760, 100), delay (100); tone (buzzer, 720, 100 ) delay (150); tone (buzzer, 680, 100), delay (150); tone (buzzer, 620, 150), delay (300); tone (buzzer, 650, 200), delay (300); tone (buzzer, 1020, 80), delay (300); tone (buzzer, 1020, 80), delay (150); tone (buzzer, 1020, 80), delay (300); tone (buzzer, 380, 100); delay (300); tone (buzzer, 500, 100), delay (300); tone (buzzer, 760, 100), delay (100); tone (buzzer, 720, 100), delay (150); tone (buzzer , 680, 100), delay (150); tone (buzzer, 620, 150), delay (300); tone (buzzer, 650, 150), delay (300); tone (buzzer, 380, 100), delay ( 150), tone (buzzer, 430, 100), delay (150); tone (buzzer, 500, 100), delay (300); tone (buzzer, 430, 100), delay (150); tone (buzzer, 500 , 100), delay (100); tone (buzzer, 570, 100), delay (420); tone (buzzer, 585, 100), delay (450); tone (buzzer, 550, 100), delay (420) ; tone (buzzer, 500, 100), delay (360); tone (buzzer, 380, 100), delay (300); tone (buzzer, 500, 100), delay (300); tone (buzzer, 500, 100 ) delay (150); tone (buzzer, 500, 100), delay (300); tone (buzzer, 500, 100), delay (300); tone (buzzer, 760, 100), delay (100); tone (buzzer, 720, 100), delay (150); tone (buzzer, 680, 100), delay (150); tone (buzzer, 620, 150), delay (300); tone (buzzer, 650, 150); delay (300); tone (buzzer, 380, 100), delay (150); tone (buzzer, 430, 100), delay (150); tone (buzzer, 500, 100), delay (300); tone (buzzer , 430, 100), delay (150); tone (buzzer, 500, 100), delay (100); tone (buzzer, 570, 100), delay (220); tone (buzzer, 500, 100), delay ( 300), tone (buzzer, 760, 100), delay (100); tone (buzzer, 720, 100), delay (150); tone (buzzer, 680, 100), delay (150); tone (buzzer, 620 , 150), delay (300); tone (buzzer, 650, 200), delay (300); tone (buzzer, 1020, 80), delay (300); tone (buzzer, 1020, 80), delay (150) ; tone (buzzer, 1020, 80), delay (300); tone (buzzer, 380, 100), delay (300); tone (buzzer, 500, 100), delay (300); tone (buzzer, 760, 100 ) delay (100); tone (buzzer, 720, 100), delay (150); tone (buzzer, 680, 100), delay (150); tone (buzzer, 620, 150), delay (300); tone (buzzer, 650, 150), delay (300); tone (buzzer, 380, 100), delay (150); tone (buzzer, 430, 100), delay (150); tone (buzzer, 500, 100); delay (300); tone (buzzer, 430, 100), delay (150); tone (buzzer, 500, 100), delay (100); tone (buzzer, 570, 100), delay (420); tone (buzzer , 585, 100), delay (450); tone (buzzer, 550, 100), delay (420); tone (buzzer, 500, 100), delay (360); tone (buzzer, 380, 100), delay ( 300), tone (buzzer, 500, 100), delay (300); tone (buzzer, 500, 100), delay (150); tone (buzzer, 500, 100), delay (300); tone (buzzer, 500 , 60); delay (150); tone (buzzer, 500, 80); delay (300); tone (buzzer, 500, 60); delay (350); tone (buzzer, 500, 80); delay (150) ; tone (buzzer, 580, 80); delay (350); tone (buzzer, 660, 80); delay (150); tone (buzzer, 500, 80); delay (300); tone (buzzer, 430, 80 ); delay (150); tone (buzzer, 380, 80); delay (600); tone (buzzer, 500, 60); delay (150); tone (buzzer, 500, 80); delay (300); tone (buzzer, 500, 60); delay (350); tone (buzzer, 500, 80); delay (150); tone (buzzer, 580, 80); delay (150); tone (buzzer, 660, 80); delay (550); tone (buzzer, 870, 80); delay (325); tone (buzzer, 760, 80); delay (600); tone (buzzer, 500, 60); delay (150); tone (buzzer , 500, 80); delay (300); tone (buzzer, 500, 60); delay (350); tone (buzzer, 500, 80); delay (150); tone (buzzer, 580, 80), delay ( 350), tone (buzzer, 660, 80); delay (150); tone (buzzer, 500, 80); delay (300); tone (buzzer, 430, 80); delay (150); tone (buzzer, 380 , 80), delay (600); tone (buzzer, 660, 100), delay (150); tone (buzzer, 660, 100), delay (300); tone (buzzer, 660, 100), delay (300) ; tone (buzzer, 510, 100), delay (100); tone (buzzer, 660, 100), delay (300); tone (buzzer, 770, 100), delay (550); tone (buzzer, 380, 100 ) delay (575);}
The Circuit
Demo Video
Hope you had fun, this time we refer to our next tutorial, the magical world of open source coupon. See you soon!
See Pictures and Read more : Back to 80's: let's play Super Mario Bros. theme for Arduino
ไม่มีความคิดเห็น:
แสดงความคิดเห็น