a journal
blog*spot
-->

thefootprints

a chengsiong publication





archives . affiliates .

TOP OF THE DAY

31 July 2006

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

while (d
{
for (k=0; k
PORTAbits.RA2=~PORTAbits.RA2; // toggles sound port RA2
}
}
}

if (PORTCbits.RC6==1)
{
PORTB=0b11000000;
PORTAbits.RA0=0;
PORTAbits.RA1=0;
PORTAbits.RA2=1;
}
Delay10KTCYx(10);
if(PORTCbits.RC4==0)
while(!PORTCbits.RC4)
{
PORTD=0b1000000; //0-9
Delay10KTCYx(50);
PORTD=0b1111001; //1
Delay10KTCYx(50);
PORTD=0b0100100;//2
Delay10KTCYx(50);
PORTD=0b0110000;//3
Delay10KTCYx(50);
PORTD=0b0011001;//4
Delay10KTCYx(50);
PORTD=0b0010010;//5
Delay10KTCYx(50);
PORTD=0b0000010;//6
Delay10KTCYx(50);
PORTD=0b1111000;//7
Delay10KTCYx(50);
PORTD=0b0000000;//8
Delay10KTCYx(50);
PORTD=0b0010000;//9
Delay10KTCYx(50);
for(j=0;j<6;j++) i="0;i<125;i++)" porte="2;" portd="0b01111001;" porte="1;" portd="0b1000000;" i="0;i<125;i++)">
{
PORTE=2;
PORTD=0b01111001;
Delay1KTCYx(2);
PORTE=1;
PORTD=0b01111001;
Delay1KTCYx(2);
}
break;
case 2:for(i=0;i<125;i++)>
{
PORTE=2;
PORTD=0b01111001;
Delay1KTCYx(2);
PORTE=1;
PORTD=0b0100100;
Delay1KTCYx(2);
}
break;
case 3:for(i=0;i<125;i++)>
{
PORTE=2;
PORTD=0b01111001;
Delay1KTCYx(2);
PORTE=1;
PORTD=0b0110000;
Delay1KTCYx(2);
}
break;
case 4:for(i=0;i<125;i++)>
{
PORTE=2;
PORTD=0b01111001;
Delay1KTCYx(2);
PORTE=1;
PORTD=0b0011001;
Delay1KTCYx(2);
}
break;
case 5:for(i=0;i<125;i++)>
{
PORTE=2;
PORTD=0b01111001;
Delay1KTCYx(2);
PORTE=1;
PORTD=0b0010010;
Delay1KTCYx(2);
}
break;
Delay10KTCYx(10);
}
}
}
if (PORTCbits.RC7==1)
{
PORTD=0b1000000;
}
}

don ask me what's all this. 'cause i also half bucket water. then that teacher keep gl me. make me dl only.