after d.goh maths lesson, its time for some programming lesson.
#include #pragma romdata // to store score sheet in ROM to convert to RAM space #include //Musical notes 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16,17 18 char sc_note[30]={25,29,30,32,33,34,35,36,38,40,42,44,45,46,47,50,52,50}; //Musical notes 1 2 3 4 5 6 7 8 9 10 12 13 14 15 16 17 18 int sc_time[30]={4,4,4,3,3,3,3,1,2,2, 2, 2, 2, 2, 2, 2, 2}; //char sc_note[30]={10,20,30,40,50,60,70,80};//int sc_time[30]={1,1,1,1,1,1,1,1}; #pragma codeint t,d,i,k,x,j=0;int time; char note;//tuning;
void main() { ADCON1=0x0F;// Set Port A, B & E as digital I/O TRISA=0b11100000;//bit 0 - 8 of Port A as output(RA0 - RA5 for Port A) //tuning = 1; TRISB=0b11000000; TRISC=0b11111111; TRISE=0b00000000; TRISD=0b00000000; PORTE=1; if (PORTCbits.RC6==0) { PORTB=0b11111111; PORTAbits.RA0=1; PORTAbits.RA1=1; Delay10KTCYx(20); PORTB=0b11000000; PORTAbits.RA0=0; PORTAbits.RA1=0; Delay10KTCYx(20);
for (i=0; i<30;> { for (t=0; t<250; note="sc_note[i]; // called out the note above time=sc_time[i]*1100; //change factor to adjust tempo d=0;// d character start