import utmech.mechanompu.io.*; public class LedScroll { private static int speed=5; //点灯速度 private static final int unit_time=50; public static void main(String arg[]) { System.out.println("Speed="+speed); //最初のスピードを表示 while(true) { // キーの押し下げ状態の読みとり int key_code=key.scan(); if(key_code==key.f1) //F1が押されていたら break; // 終了 if(key_code >= 0 && key_code <= 0x0f) { //0からFだったら speed=key_code; // 点灯速度を変更 System.out.println("Speed="+speed); } //順番に点灯 try { led.set(led.l0); Thread.sleep(speed*unit_time); led.set(led.l1); Thread.sleep(speed*unit_time); led.set(led.l2); Thread.sleep(speed*unit_time); led.set(led.l3); Thread.sleep(speed*unit_time); } //sleepで発生の可能性のある例外を捕捉 catch(InterruptedException e) { System.out.println(e); } } } }