#include "SPI.h" #include "pfatfs.h" char buffer[ 256 ]; void setup() { Serial.begin( 9600 ); delay( 100 ); FatFs.begin( P2_2 ); // Port 2, pin 2 is connected to the chip select on the SD card reader unsigned err; if( (err = FatFs.open( "spock.raw" )) != FR_OK ) { Serial.print( "Can't open spock.raw: " ); Serial.println( err ); return; } pinMode( P2_1, OUTPUT ); analogFrequency( 62500 ); unsigned short len = 0; while( FatFs.read( buffer, sizeof buffer, &len ) == 0 && len ) { for( unsigned i = 0; i < len; i++ ) { analogWrite( P2_1, buffer[i] ); delayMicroseconds( 30 ); // 8 bits at 11025 Hz } } } void loop( void ) { digitalWrite( P1_6, 0 ); // stop the PWM timer delay( 1000000 ); }