plays mario theme song using pwm signals

Dependencies:   BSP_DISCO_L476VG LCD_DISCO_L476VG mbed

Files at this revision

API Documentation at this revision

Comitter:
steeler331
Date:
Thu Apr 26 20:57:55 2018 +0000
Commit message:
plays mario theme song using pwm signals

Changed in this revision

BSP_DISCO_L476VG.lib Show annotated file Show diff for this revision Revisions of this file
LCD_DISCO_L476VG.lib Show annotated file Show diff for this revision Revisions of this file
main.cpp Show annotated file Show diff for this revision Revisions of this file
mbed.bld Show annotated file Show diff for this revision Revisions of this file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/BSP_DISCO_L476VG.lib	Thu Apr 26 20:57:55 2018 +0000
@@ -0,0 +1,1 @@
+https://developer.mbed.org/teams/ST/code/BSP_DISCO_L476VG/#472232f07925
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/LCD_DISCO_L476VG.lib	Thu Apr 26 20:57:55 2018 +0000
@@ -0,0 +1,1 @@
+https://developer.mbed.org/teams/ST/code/LCD_DISCO_L476VG/#6ac2ed34f595
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Thu Apr 26 20:57:55 2018 +0000
@@ -0,0 +1,1141 @@
+#include "mbed.h"
+
+PwmOut mypwm(PWM_OUT);
+
+#define UP 1
+#define DOWN 2
+
+void noteC_octave4 (void)
+{
+    mypwm.period_us(3788);
+    mypwm.pulsewidth_us(1894);
+}
+
+void noteD_octave4 (void)
+{
+    mypwm.period_us(3367);
+    mypwm.pulsewidth_us(1683);
+}
+
+void noteE_octave4 (void)
+{
+    mypwm.period_us(3030);
+    mypwm.pulsewidth_us(1515);
+}
+
+void noteF_octave4 (void)
+{
+    mypwm.period_us(2841);
+    mypwm.pulsewidth_us(1420);
+}
+
+void noteG_octave4 (void)
+{
+    mypwm.period_us(2525);
+    mypwm.pulsewidth_us(1262);
+}
+
+void noteA_octave4 (void)
+{
+    mypwm.period_us(2273);
+    mypwm.pulsewidth_us(1136);
+}
+
+void noteAsharp_octave4 (void)
+{
+    mypwm.period_us(2146);
+    mypwm.pulsewidth_us(1073);
+}
+ 
+ void no_frequency (void)
+{
+    mypwm.period_ms(1000);
+    mypwm.pulsewidth_ms(500);
+}  
+
+void noteE5 (void)
+{
+    mypwm.period_us(1515);
+    mypwm.pulsewidth_us(757);
+} 
+
+void noteC5 (void)
+{
+    mypwm.period_us(1961);
+    mypwm.pulsewidth_us(980);
+} 
+
+void noteG5 (void)
+{
+    mypwm.period_us(1299);
+    mypwm.pulsewidth_us(649);
+} 
+
+void noteFsharp4 (void)
+{
+    mypwm.period_us(2632);
+    mypwm.pulsewidth_us(1316);
+} 
+
+void noteDsharp4 (void)
+{
+    mypwm.period_us(3125);
+    mypwm.pulsewidth_us(1562);
+} 
+
+void noteLB4 (void)
+{
+    mypwm.period_us(2083);
+    mypwm.pulsewidth_us(1041);
+} 
+
+void noteA4 (void)
+{
+    mypwm.period_us(2272);
+    mypwm.pulsewidth_us(1136);
+} 
+
+void noteHA4 (void)
+{
+    mypwm.period_us(2222);
+    mypwm.pulsewidth_us(1111);
+} 
+
+void noteLA4 (void)
+{
+    mypwm.period_us(2325);
+    mypwm.pulsewidth_us(1162);
+} 
+
+void noteFsharp5 (void)
+{
+    mypwm.period_us(1316);
+    mypwm.pulsewidth_us(658);
+} 
+
+void noteA5 (void)
+{
+    mypwm.period_us(1162);
+    mypwm.pulsewidth_us(581);
+} 
+
+void noteF5 (void)
+{
+    mypwm.period_us(1428);
+    mypwm.pulsewidth_us(714);
+} 
+
+void noteHC5 (void)
+{
+    mypwm.period_us(1923);
+    mypwm.pulsewidth_us(861);
+} 
+
+void noteD5 (void)
+{
+    mypwm.period_us(1724);
+    mypwm.pulsewidth_us(862);
+} 
+
+void noteB4 (void)
+{
+    mypwm.period_us(2000);
+    mypwm.pulsewidth_us(1000);
+} 
+
+void noteLFsharp5 (void)
+{
+    mypwm.period_us(1388);
+    mypwm.pulsewidth_us(694);
+} 
+
+void noteLF5 (void)
+{
+    mypwm.period_us(1470);
+    mypwm.pulsewidth_us(735);
+} 
+
+void noteDsharp5 (void)
+{
+    mypwm.period_us(1613);
+    mypwm.pulsewidth_us(807);
+} 
+
+void noteLE5 (void)
+{
+    mypwm.period_us(1538);
+    mypwm.pulsewidth_us(769);
+} 
+
+void noteCsharp5 (void)
+{
+    mypwm.period_us(1754);
+    mypwm.pulsewidth_us(877);
+} 
+
+void noteC6 (void)
+{
+    mypwm.period_us(980);
+    mypwm.pulsewidth_us(490);
+} 
+
+void noteHD5 (void)
+{
+    mypwm.period_us(1709);
+    mypwm.pulsewidth_us(854);
+    
+}  
+
+void noteLCsharp5 (void)
+{
+    mypwm.period_us(1818);
+    mypwm.pulsewidth_us(909);
+    
+}  
+
+void noteHA5 (void)
+{
+    mypwm.period_us(1149);
+    mypwm.pulsewidth_us(574);
+    
+}  
+
+int main() {
+    
+noteE5();
+wait_ms(100);
+
+no_frequency();
+wait_ms(150);
+
+noteE5();
+wait_ms(100);
+
+no_frequency();
+wait_ms(300);
+
+noteE5();
+wait_ms(100);
+
+no_frequency();
+wait_ms(300);
+
+noteC5();
+wait_ms(100);
+
+no_frequency();
+wait_ms(100);
+
+noteE5();
+wait_ms(100);
+
+no_frequency();
+wait_ms(300);
+
+noteG5();
+wait_ms(100);
+
+no_frequency();
+wait_ms(550);
+
+noteFsharp4();
+wait_ms(100);
+
+no_frequency();
+wait_ms(575);
+
+noteC5();
+wait_ms(100);
+
+no_frequency();
+wait_ms(450);
+
+noteFsharp4();
+wait_ms(100);
+
+no_frequency();
+wait_ms(400);
+
+noteDsharp4();
+wait_ms(100);
+
+no_frequency();
+wait_ms(500);
+
+noteA4();
+wait_ms(100);
+
+no_frequency();
+wait_ms(300);
+
+noteB4();
+wait_ms(80);
+
+no_frequency();
+wait_ms(330);
+
+noteHA4();
+wait_ms(100);
+
+no_frequency();
+wait_ms(150);
+
+noteLA4();
+wait_ms(100);
+
+no_frequency();
+wait_ms(300);
+
+noteFsharp4();
+wait_ms(100);
+
+no_frequency();
+wait_ms(200);
+
+noteE5();
+wait_ms(80);
+
+no_frequency();
+wait_ms(200);
+
+noteFsharp5();
+wait_ms(50);
+
+no_frequency();
+wait_ms(150);
+
+noteA5();
+wait_ms(100);
+
+no_frequency();
+wait_ms(300);
+
+noteF5();
+wait_ms(80);
+
+no_frequency();
+wait_ms(150);
+
+noteFsharp5();
+wait_ms(50);
+
+no_frequency();
+wait_ms(350);
+
+noteE5();
+wait_ms(80);
+
+no_frequency();
+wait_ms(300);
+
+noteHC5();
+wait_ms(80);
+
+no_frequency();
+wait_ms(150);
+
+noteD5();
+wait_ms(80);
+
+no_frequency();
+wait_ms(150);
+
+noteLB4();
+wait_ms(80);
+
+no_frequency();
+wait_ms(500);
+
+noteC5();
+wait_ms(100);
+
+no_frequency();
+wait_ms(450);
+
+noteFsharp4();
+wait_ms(100);
+
+no_frequency();
+wait_ms(400);
+
+noteDsharp4();
+wait_ms(100);
+
+no_frequency();
+wait_ms(500);
+
+noteA4();
+wait_ms(100);
+
+no_frequency();
+wait_ms(300);
+
+noteLB4();
+wait_ms(80);
+
+no_frequency();
+wait_ms(330);
+
+noteHA4();
+wait_ms(100);
+
+no_frequency();
+wait_ms(150);
+
+noteLA4();
+wait_ms(100);
+
+no_frequency();
+wait_ms(300);
+
+noteFsharp4();
+wait_ms(100);
+
+no_frequency();
+wait_ms(200);
+
+noteE5();
+wait_ms(80);
+
+no_frequency();
+wait_ms(200);
+
+noteFsharp5();
+wait_ms(50);
+
+no_frequency();
+wait_ms(150);
+
+noteA5();
+wait_ms(100);
+
+no_frequency();
+wait_ms(300);
+
+noteF5();
+wait_ms(80);
+
+no_frequency();
+wait_ms(150);
+
+noteFsharp5();
+wait_ms(50);
+
+no_frequency();
+wait_ms(350);
+
+noteE5();
+wait_ms(80);
+
+no_frequency();
+wait_ms(300);
+
+noteHC5();
+wait_ms(80);
+
+no_frequency();
+wait_ms(150);
+
+noteD5();
+wait_ms(80);
+
+no_frequency();
+wait_ms(150);
+
+noteLB4();
+wait_ms(80);
+
+no_frequency();
+wait_ms(500);
+
+noteB4();
+wait_ms(100);
+
+no_frequency();
+wait_ms(300);
+
+noteFsharp5();
+wait_ms(100);
+
+no_frequency();
+wait_ms(100);
+
+noteLFsharp5();
+wait_ms(100);
+
+no_frequency();
+wait_ms(150);
+
+noteLF5();
+wait_ms(100);
+
+no_frequency();
+wait_ms(150);
+
+noteDsharp5();
+wait_ms(150);
+
+no_frequency();
+wait_ms(300);
+
+noteLE5();
+wait_ms(150);
+
+no_frequency();
+wait_ms(300);
+
+noteFsharp4();
+wait_ms(100);
+
+no_frequency();
+wait_ms(150);
+
+noteLA4();
+wait_ms(100);
+
+no_frequency();
+wait_ms(150);
+
+noteB4();
+wait_ms(100);
+
+no_frequency();
+wait_ms(300);
+
+noteLA4();
+wait_ms(100);
+
+no_frequency();
+wait_ms(150);
+
+noteB4();
+wait_ms(100);
+
+no_frequency();
+wait_ms(100);
+
+noteCsharp5();
+wait_ms(100);
+
+no_frequency();
+wait_ms(220);
+
+noteB4();
+wait_ms(100);
+
+no_frequency();
+wait_ms(300);
+
+noteFsharp5();
+wait_ms(100);
+
+no_frequency();
+wait_ms(100);
+
+noteLFsharp5();
+wait_ms(100);
+
+no_frequency();
+wait_ms(150);
+
+noteLF5();
+wait_ms(100);
+
+no_frequency();
+wait_ms(150);
+
+noteDsharp5();
+wait_ms(150);
+
+no_frequency();
+wait_ms(300);
+
+noteLE5();
+wait_ms(200);
+
+no_frequency();
+wait_ms(300);
+
+noteC6();
+wait_ms(80);
+
+no_frequency();
+wait_ms(300);
+
+noteC6();
+wait_ms(80);
+
+no_frequency();
+wait_ms(150);
+
+noteC6();
+wait_ms(80);
+
+no_frequency();
+wait_ms(300);
+
+noteFsharp4();
+wait_ms(100);
+
+no_frequency();
+wait_ms(300);
+
+noteB4();
+wait_ms(100);
+
+no_frequency();
+wait_ms(300);
+
+noteFsharp5();
+wait_ms(100);
+
+no_frequency();
+wait_ms(100);
+
+noteLFsharp5();
+wait_ms(100);
+
+no_frequency();
+wait_ms(150);
+
+noteLF5();
+wait_ms(100);
+
+no_frequency();
+wait_ms(150);
+
+noteDsharp5();
+wait_ms(150);
+
+no_frequency();
+wait_ms(300);
+
+noteLE5();
+wait_ms(150);
+
+no_frequency();
+wait_ms(300);
+
+noteFsharp4();
+wait_ms(100);
+
+no_frequency();
+wait_ms(150);
+
+noteLA4();
+wait_ms(100);
+
+no_frequency();
+wait_ms(150);
+
+noteB4();
+wait_ms(100);
+
+no_frequency();
+wait_ms(300);
+
+noteLA4();
+wait_ms(100);
+
+no_frequency();
+wait_ms(150);
+
+noteB4();
+wait_ms(100);
+
+no_frequency();
+wait_ms(100);
+
+noteCsharp5();
+wait_ms(100);
+
+no_frequency();
+wait_ms(420);
+
+noteHD5();
+wait_ms(100);
+
+no_frequency();
+wait_ms(450);
+
+noteLCsharp5();
+wait_ms(100);
+
+no_frequency();
+wait_ms(420);
+
+noteB4();
+wait_ms(100);
+
+no_frequency();
+wait_ms(360);
+
+noteFsharp4();
+wait_ms(100);
+
+no_frequency();
+wait_ms(300);
+
+noteB4();
+wait_ms(100);
+
+no_frequency();
+wait_ms(300);
+
+noteB4();
+wait_ms(100);
+
+no_frequency();
+wait_ms(150);
+
+noteB4();
+wait_ms(100);
+
+no_frequency();
+wait_ms(300);
+
+noteB4();
+wait_ms(100);
+
+no_frequency();
+wait_ms(300);
+
+noteFsharp5();
+wait_ms(100);
+
+no_frequency();
+wait_ms(100);
+
+noteLFsharp5();
+wait_ms(100);
+
+no_frequency();
+wait_ms(150);
+
+noteLF5();
+wait_ms(100);
+
+no_frequency();
+wait_ms(150);
+
+noteDsharp5();
+wait_ms(150);
+
+no_frequency();
+wait_ms(300);
+
+noteLE5();
+wait_ms(150);
+
+no_frequency();
+wait_ms(300);
+
+noteFsharp4();
+wait_ms(100);
+
+no_frequency();
+wait_ms(150);
+
+noteLA4();
+wait_ms(100);
+
+no_frequency();
+wait_ms(150);
+
+noteB4();
+wait_ms(100);
+
+no_frequency();
+wait_ms(300);
+
+noteLA4();
+wait_ms(100);
+
+no_frequency();
+wait_ms(150);
+
+noteB4();
+wait_ms(100);
+
+no_frequency();
+wait_ms(100);
+
+noteCsharp5();
+wait_ms(100);
+
+no_frequency();
+wait_ms(220);
+
+noteB4();
+wait_ms(100);
+
+no_frequency();
+wait_ms(300);
+
+noteFsharp5();
+wait_ms(100);
+
+no_frequency();
+wait_ms(100);
+
+noteLFsharp5();
+wait_ms(100);
+
+no_frequency();
+wait_ms(150);
+
+noteLF5();
+wait_ms(100);
+
+no_frequency();
+wait_ms(150);
+
+noteDsharp5();
+wait_ms(150);
+
+no_frequency();
+wait_ms(300);
+
+noteLE5();
+wait_ms(200);
+
+no_frequency();
+wait_ms(300);
+
+noteC6();
+wait_ms(80);
+
+no_frequency();
+wait_ms(300);
+
+noteC6();
+wait_ms(80);
+
+no_frequency();
+wait_ms(150);
+
+noteC6();
+wait_ms(80);
+
+no_frequency();
+wait_ms(300);
+
+noteFsharp4();
+wait_ms(100);
+
+no_frequency();
+wait_ms(300);
+
+noteB4();
+wait_ms(100);
+
+no_frequency();
+wait_ms(300);
+
+noteFsharp5();
+wait_ms(100);
+
+no_frequency();
+wait_ms(100);
+
+noteLFsharp5();
+wait_ms(100);
+
+no_frequency();
+wait_ms(150);
+
+noteLF5();
+wait_ms(100);
+
+no_frequency();
+wait_ms(150);
+
+noteDsharp5();
+wait_ms(150);
+
+no_frequency();
+wait_ms(300);
+
+noteLE5();
+wait_ms(150);
+
+no_frequency();
+wait_ms(300);
+
+noteFsharp4();
+wait_ms(100);
+
+no_frequency();
+wait_ms(150);
+
+noteLA4();
+wait_ms(100);
+
+no_frequency();
+wait_ms(150);
+
+noteB4();
+wait_ms(100);
+
+no_frequency();
+wait_ms(300);
+
+noteLA4();
+wait_ms(100);
+
+no_frequency();
+wait_ms(150);
+
+noteB4();
+wait_ms(100);
+
+no_frequency();
+wait_ms(100);
+
+noteCsharp5();
+wait_ms(100);
+
+no_frequency();
+wait_ms(420);
+
+noteHD5();
+wait_ms(100);
+
+no_frequency();
+wait_ms(450);
+
+noteLCsharp5();
+wait_ms(100);
+
+no_frequency();
+wait_ms(420);
+
+noteB4();
+wait_ms(100);
+
+no_frequency();
+wait_ms(360);
+
+noteFsharp4();
+wait_ms(100);
+
+no_frequency();
+wait_ms(300);
+
+noteB4();
+wait_ms(100);
+
+no_frequency();
+wait_ms(300);
+
+noteB4();
+wait_ms(100);
+
+no_frequency();
+wait_ms(150);
+
+noteB4();
+wait_ms(100);
+
+no_frequency();
+wait_ms(300);
+
+noteB4();
+wait_ms(60);
+
+no_frequency();
+wait_ms(150);
+
+noteB4();
+wait_ms(80);
+
+no_frequency();
+wait_ms(300);
+
+noteB4();
+wait_ms(60);
+
+no_frequency();
+wait_ms(350);
+
+noteB4();
+wait_ms(80);
+
+no_frequency();
+wait_ms(150);
+
+noteD5();
+wait_ms(80);
+
+no_frequency();
+wait_ms(350);
+
+noteE5();
+wait_ms(80);
+
+no_frequency();
+wait_ms(150);
+
+noteB4();
+wait_ms(80);
+
+no_frequency();
+wait_ms(300);
+
+noteLA4();
+wait_ms(80);
+
+no_frequency();
+wait_ms(150);
+
+noteFsharp4();
+wait_ms(80);
+
+no_frequency();
+wait_ms(600);
+
+noteB4();
+wait_ms(60);
+
+no_frequency();
+wait_ms(150);
+
+noteB4();
+wait_ms(80);
+
+no_frequency();
+wait_ms(300);
+
+noteB4();
+wait_ms(60);
+
+no_frequency();
+wait_ms(350);
+
+noteB4();
+wait_ms(80);
+
+no_frequency();
+wait_ms(150);
+
+noteD5();
+wait_ms(80);
+
+no_frequency();
+wait_ms(150);
+
+noteE5();
+wait_ms(80);
+
+no_frequency();
+wait_ms(550);
+
+noteHA5();
+wait_ms(80);
+
+no_frequency();
+wait_ms(325);
+
+noteFsharp5();
+wait_ms(80);
+
+no_frequency();
+wait_ms(600);
+
+noteB4();
+wait_ms(60);
+
+no_frequency();
+wait_ms(150);
+
+noteB4();
+wait_ms(80);
+
+no_frequency();
+wait_ms(300);
+
+noteB4();
+wait_ms(60);
+
+no_frequency();
+wait_ms(350);
+
+noteB4();
+wait_ms(80);
+
+no_frequency();
+wait_ms(150);
+
+noteD5();
+wait_ms(80);
+
+no_frequency();
+wait_ms(350);
+
+noteE5();
+wait_ms(80);
+
+no_frequency();
+wait_ms(150);
+
+noteB4();
+wait_ms(80);
+
+no_frequency();
+wait_ms(300);
+
+noteLA4();
+wait_ms(80);
+
+no_frequency();
+wait_ms(150);
+
+noteFsharp4();
+wait_ms(80);
+
+no_frequency();
+wait_ms(600);
+
+noteE5();
+wait_ms(100);
+
+no_frequency();
+wait_ms(150);
+
+noteE5();
+wait_ms(100);
+
+no_frequency();
+wait_ms(300);
+
+noteE5();
+wait_ms(100);
+
+no_frequency();
+wait_ms(300);
+
+noteC5();
+wait_ms(100);
+
+no_frequency();
+wait_ms(100);
+
+noteE5();
+wait_ms(100);
+
+no_frequency();
+wait_ms(300);
+
+noteG5();
+wait_ms(100);
+
+no_frequency();
+wait_ms(550);
+
+noteFsharp4();
+wait_ms(100);
+
+no_frequency();
+wait_ms(575);
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Thu Apr 26 20:57:55 2018 +0000
@@ -0,0 +1,1 @@
+https://os.mbed.com/users/mbed_official/code/mbed/builds/5aab5a7997ee
\ No newline at end of file