Este es el código de Mikroc Para realizar un pianito, con el pic16f887 con oscilador interno..
void main ()
{
osccon=0x77;
TRISC=0XFF;
TRISD=0X00;
Sound_init(&PORTD,0);
for(;;)
{
if (Button(&PORTC, 0, 1, 1)) Sound_Play(522,100); //Do
if (Button(&PORTC, 1, 1, 1)) Sound_Play(588,100); //Re
if (Button(&PORTC, 2, 1, 1)) Sound_Play(660,100); //Mi
if (Button(&PORTC, 3, 1, 1)) Sound_Play(698,100); //Fa
if (Button(&PORTC, 4, 1, 1)) Sound_Play(784,100); //Sol
if (Button(&PORTC, 5, 1, 1)) Sound_Play(880,100); //La
if (Button(&PORTC, 6, 1, 1)) Sound_Play(988,100); //Si
if (Button(&PORTC, 7, 1, 1)) Sound_Play(783,100); //Do
}
}
Comentarios