'---------------Title-------------- ' File......4 TSA Music'10.pbp ' Started....1/25/10 ' Microcontroller used: Microchip Technology 16F88 ' microchip.com ' PicBasic Pro Code: micro-Engineering Labs, Inc. ' melabs.com '--------Program Desciption-------- ' TSA Music Production Program 2010: Track 4 '---------Revision History--------- ' 2/1/10 Changed VAR to CON ' 2/11/10 Program Finalized '-----------Initialization--------- define OSC 20 ' Sets microcontroller operating frequency ' to 20 MHz. TRISB = %11111000 ' Sets up pins RB0 - 3 of PORTB as an output PORTB = %00000000 ' Sets all pins on PORTB to low (0V). ' The variable "x" represents the eighth note. The length of time that the ' eighth note (x) is played is deteremined by the value set at 200. ' A quarter note is two times an eighth note or 2x. x var word ' These are the constants that we used to declare the frequencies as notes. ' For example shg represents Super High G which has a frequency of 1568 Hz. shg con 1568 shef con 1244 shc con 1046 shbf con 932 shaf con 830 hg con 784 hf con 698 hef con 622 hd con 587 hc con 523 hbf con 466 haf con 415 g con 392 f con 349 ef con 311 d con 293 c con 261 bf con 233 af con 208 lg con 196 lf con 174 lef con 155 ld con 146 lc con 130 lbf con 116 laf con 103 slg con 98 slf con 87 slef con 78 sld con 73 slc con 65 '-------------Main Code------------ x = 200 ' An eighth note (x) will be 200 ms long. Pause 1000 ' Pause 1000 ms before starting generating tones ' line1 freqout 1, 6*x, lc ' We use FREQOUT to generate a tone. 1 represents ' output pin RB1 on the Pic16F88. "x" symbolizes the ' eighth note. "lc" is defined as the frequecy 392 Hz. freqout 1, 4*x, slg freqout 1, 4*x, ld freqout 1, 6*x, lc freqout 1, 4*x, slg freqout 1, 4*x, ld freqout 1, 6*x, lc 'line 2 freqout 1, 5*x, slg freqout 1, 3*x, lc freqout 1, 4*x, lef freqout 1, 4*x, ld 'line 3 freqout 1, 6*x, lc freqout 1, 4*x, slg freqout 1, 4*x, ld freqout 1, 6*x, lc freqout 1, 4*x, slg freqout 1, 4*x, ld freqout 1, 6*x, lc freqout 1, 4*x, slg 'line 4 FReqout 1, 3*x, lc FReqout 1, 4*x, lef FReqout 1, 4*x, ld FReqout 1, 4*x, ld FReqout 1, x, 0 FReqout 1, 14*x, lc FReqout 1, 14*x, laf 'line 5 FReqout 1, 8*x, lbf freqout 1, 6*x, slg FReqout 1, 14*x, lc 'line 6 FReqout 1, 14*x, laf FReqout 1, 8*x, lbf freqout 1, 6*x, slg FReqout 1, 2*x, lc FReqout 1, 2*x, lc FReqout 1, 2*x, lc 'line 7 FReqout 1, 4*x, lc FReqout 1, 6*x, lc FReqout 1, 4*x, lg FReqout 1, 4*x, ld FReqout 1, 6*x, lc FReqout 1, 4*x, slg FReqout 1, 4*x, ld FReqout 1, 6*x, lc FReqout 1, 5*x, slg FReqout 1, 3*x, lc FReqout 1, 4*x, lef FReqout 1, 4*x, ld FReqout 1, 6*x, lc 'line 8 FReqout 1, 4*x, slg FReqout 1, 4*x, ld FReqout 1, 6*x, lc FReqout 1, 4*x, slg FReqout 1, 4*x, ld FReqout 1, 6*x, lc FReqout 1, 5*x, slg 'line 9 & 10 FReqout 1, 8*x, lc end