Tadao Iida / Mbed 2 deprecated music

Dependencies:   TextLCD mbed SDFileSystem

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers main.cpp Source File

main.cpp

00001 #include "mbed.h"
00002 #include "TextLCD.h"
00003 #include "SDFileSystem.h"
00004 #include "MySound.h"
00005 
00006 TextLCD lcd(p24, p26, p27, p28, p29, p30);
00007 SDFileSystem sd(p5, p6, p7, p8, "sd") ;
00008 MySound music(p21) ;  
00009 
00010 
00011 int main() {
00012     char pitch ;
00013     int scale;
00014     char ln;
00015     FILE *fp;
00016     int n;
00017     
00018     if ( (fp = fopen("/sd/music.txt","r")) == NULL ) {
00019         printf("Open Failed. \n") ;
00020         return -1;
00021     }
00022     lcd.printf("Silent Night"); 
00023        
00024     while( (n = fscanf(fp,"%c %d %c ",&pitch,&scale,&ln)) != EOF ){
00025             printf("%d %c %d %c\n",n,pitch,scale,ln);
00026             music.play(pitch, scale, ln) ;
00027     } 
00028    
00029     fclose(fp) ;
00030 }