[NXC] random playtone

有趣的小程式, 隨機產生1~6後發出不同音高。

=========================================

task main()
{
int a = 0;
while(true){
a = Random(5)+1;
NumOut(20,20,a);
switch(a)
{
case 1:
{ PlayTone(a*300, 40);
Wait(500);break;
}
case 2:
{ PlayTone(a*300, 40);
Wait(500);break;
}
case 3:
{ PlayTone(a*300, 40);
Wait(500);break;
}
case 4:
{ PlayTone(a*300, 40);
Wait(500);break;
}
case 5:
{ PlayTone(a*300, 40); Wait(500);break;}
case 6:
{ PlayTone(a*300, 40); Wait(500);break;}
default:
{ break;}
}
}//while
}

About CAVEDU 阿吉 - 雜工 (2521 Articles)

CAVEDU 教育團隊 打雜

Contact: Website

Leave a comment

Your email address will not be published.


*