레고 nxt의 p브릭에는 주파수를 입력받아 소리를 내어 음악을 연주하는 기능이 있다. 그 기능을 이용, 옥수수 하모니카를 연주해보았다.
package lejos;
import lejos.hardware.Sound;
import lejos.utility.Delay;
public class playtone {
public static void main(String[] args) {
Sound.playtone( 523.3 , 1000 );
Delay.msDelay( 659.3, 1000 );
Sound.playtone( 622.3 , 1000 );
Delay.msDelay( 1000 );
Sound.playtone( 523.3 , 1000 );
Delay.msDelay( 1000 );
Sound.playtone( 830.7 ,1000 );
Delay.msDelay( 1000 );
Sound.playtone( 932.4 , 1000 );
Delay.msDelay( 1000 );
Sound.playtone( 830.7 , 1000 );
Delay.msDelay( 1000 );
Sound.playtone( 830.7 , 1000 );
Delay.msDelay( 1000 );
Sound.playtone( 830.7 , 1000 );
Sound.playtone( 523.3 , 1000 );
Delay.msDelay( 659.3, 1000 );
Sound.playtone( 622.3 , 1000 );
Delay.msDelay( 1000 );
Sound.playtone( 523.3 , 1000 );
Delay.msDelay( 1000 );
Sound.playtone( 830.7 ,1000 );
Delay.msDelay( 1000 );
Sound.playtone( 932.4 , 1000 );
Delay.msDelay( 1000 );
Sound.playtone( 830.7 , 1000 );
Delay.msDelay( 1000 );
Sound.playtone( 830.7 , 1000 );
Delay.msDelay( 1000 );
Sound.playtone( 830.7 , 1000 );
}
}