/************************************************ * LADY GAGA'S "PAPARAZZI" ON PIN B0 * CONNECT A SPEAKER TO PIN B0 AND LISTEN * TO THE MUSIC! * * RYAN T ALLEY * MAY 27, 2010 ************************************************/ #include "oulib.h" // Prototypes void makeFsharp( float time ); void makeGsharp( float time ); void makeA( float time ); void makeB( float time ); void makeCsharp( float time ); void makeD( float time ); void makeE( float time ); int main (void) { float tempo = 1.0; float q = tempo / 2; // quarter note duration float e = tempo / 4; // eighth note duration float s = tempo / 8; // sixteenth note duration /* Configure port B with output pin B0 */ DDRB = 0x1; while(1) { makeA(e); delay_ms(1); // (to re-articulate notes) makeA(e); delay_ms(1); makeA(e); delay_ms(1); makeA(e); delay_ms(1); makeA(q); makeB(e); makeGsharp(q); delay_ms(1); makeGsharp(e); delay_ms(1); makeGsharp(e); delay_ms(1); makeGsharp(e); delay_ms(1); makeGsharp(q); makeA(e); makeCsharp(q); makeA(q); delay_ms(e * 1000); makeFsharp(e + s); makeGsharp(q + s); makeFsharp(e + s); makeGsharp(e + s); makeCsharp(q); makeA(e); delay_ms(q * 1000); }; return (0); } void makeFsharp( float time ) { int b = 541; float a = time / (b * 0.000001); for(int i = 0; i < (int) a; i++){ PORTB = PORTB ^ 0x1; delay_us(b); }; } void makeGsharp( float time ) { int b = 482; float a = time / (b * 0.000001); for(int i = 0; i < (int) a; i++){ PORTB = PORTB ^ 0x1; delay_us(b); }; } void makeA( float time ) { int b = 455; float a = time / (b * 0.000001); for(int i = 0; i < (int) a; i++){ PORTB = PORTB ^ 0x1; delay_us(b); }; } void makeB( float time ) { int b = 405; float a = time / (b * 0.000001); for(int i = 0; i < (int) a; i++){ PORTB = PORTB ^ 0x1; delay_us(b); }; } void makeCsharp( float time ) { int b = 361; float a = time / (b * 0.000001); for(int i = 0; i < (int) a; i++){ PORTB = PORTB ^ 0x1; delay_us(b); }; } void makeD( float time ) { int b = 341; float a = time / (b * 0.000001); for(int i = 0; i < (int) a; i++){ PORTB = PORTB ^ 0x1; delay_us(b); }; } void makeE( float time ) { int b = 303; float a = time / (b * 0.000001); for(int i = 0; i < (int) a; i++){ PORTB = PORTB ^ 0x1; delay_us(b); }; }