新人求助:android apk直接控制开发板上的4个led灯,实现流水灯

在android系统的文件目录下有如下4个文件路径,分别控制4个led亮与灭,写入1亮,0灭
public String path_led1="/sys/devices/platform/leds-gpio/leds/led1/brightness";
public String path_led2="/sys/devices/platform/leds-gpio/leds/led2/brightness";
public String path_led3="/sys/devices/platform/leds-gpio/leds/led3/brightness";
public String path_led4="/sys/devices/platform/leds-gpio/leds/led4/brightness";

如写入:String ControlBit="1";
FileOutputStream utled1=new FileOutputStream(path_led1);
utled1.write(ControlBit.getBytes());//写入控制字
utled1.close();//关闭文件
对应的第一个led灯就亮了。
但是要写一个流水灯程序,有个开关控件控制流水灯总开关,一个seekbar在开状态控制led循环亮灭速度,小白感觉过程穿插,无从下手,求有经验的大神给个思路。
更多 0

虽然没写过这样的程序,但感觉逻辑上并不复杂,很难说清,所以动手写了段代码,你看看能否对你有所帮助。

 String[] controlBits = new String[4];//四盏灯的亮灭指令数组
        String[] path_leds = new String[]{path_led1,path_led2,path_led3,path_led4};//四盏灯的路径数组
        int i=0;
        while(i<controlBits.length){//外层循环控制灯亮灭,i表示第几个灯亮

                for(int j=0;j<controlBits.length;j++){//内层循环控制对各灯发出指令
                    if(j==i){//如果该第i号灯亮
                        controlBits[j] = "1";//对该灯发出亮的指令
                    }else{
                        controlBits[j] = "0";//同时对其它灯发出灭的指令
                    }
                    //向各灯输出各自的亮灭指令
                    FileOutputStream utled=new FileOutputStream(path_leds[j]);
                    utled.write(controlBits[j].getBytes());//写入控制字
                    utled.close();//关闭文件

                }
                i++;//迭代,即开始下一轮亮灭
                if(i>=controlBits.length){//如果迭代后超过阈值,则归零。也就是第4盏灯亮过后,回到第一盏。
                    i=0;
                }
                try {
                    Thread.sleep(100);//两盏灯亮灭之间的时间间隔,数值由seekbar提供。
                } catch (InterruptedException e) {
                    // TODO Auto-generated catch block
                    e.printStackTrace();
                }

        }

关于流水灯,写一个简单的循环,循环中打开一个灯,关闭别的,关于亮灭速度就是加一个延迟时间,