diff --git a/examples/GPIO1/imgs/pinbit_microbit_Hello_Real_World.fzz b/examples/GPIO1/imgs/pinbit_microbit_Hello_Real_World.fzz old mode 100755 new mode 100644 index 63508f8..3d8fbac Binary files a/examples/GPIO1/imgs/pinbit_microbit_Hello_Real_World.fzz and b/examples/GPIO1/imgs/pinbit_microbit_Hello_Real_World.fzz differ diff --git a/examples/GPIO1/imgs/pinbit_microbit_Hello_Real_World.png b/examples/GPIO1/imgs/pinbit_microbit_Hello_Real_World.png old mode 100755 new mode 100644 index 9b7e938..dd36942 Binary files a/examples/GPIO1/imgs/pinbit_microbit_Hello_Real_World.png and b/examples/GPIO1/imgs/pinbit_microbit_Hello_Real_World.png differ diff --git a/examples/GPIO1/main.js b/examples/GPIO1/main.js old mode 100755 new mode 100644 index 0cdeefa..28647b4 --- a/examples/GPIO1/main.js +++ b/examples/GPIO1/main.js @@ -4,30 +4,32 @@ var gpioPort0; var blinkEnable; -async function connect(){ - microBitBle = await microBitBleFactory.connect(); - msg.innerHTML=("micro:bit BLE接続しました。"); - var gpioAccess = await microBitBle.requestGPIOAccess(); - var mbGpioPorts = gpioAccess.ports; - gpioPort0 = mbGpioPorts.get(0); - await gpioPort0.export("out"); //port0 out - blinkEnable = true; - LEDblink(); +async function connect() { + microBitBle = await microBitBleFactory.connect(); + msg.innerHTML = "micro:bit BLE接続しました。"; + var gpioAccess = await microBitBle.requestGPIOAccess(); + var mbGpioPorts = gpioAccess.ports; + gpioPort0 = mbGpioPorts.get(0); + await gpioPort0.export("out"); //port0 out + gpioPort1 = mbGpioPorts.get(1); + await gpioPort1.export("out"); // port1 out + blinkEnable = true; + LEDblink(); } -async function disconnect(){ - blinkEnable = false; - await microBitBle.disconnect(); - msg.innerHTML=("micro:bit BLE接続を切断しました。"); +async function disconnect() { + blinkEnable = false; + await microBitBle.disconnect(); + msg.innerHTML = "micro:bit BLE接続を切断しました。"; } -async function LEDblink(){ - var gpio0Val = 0; - while ( blinkEnable ){ - gpio0Val = (gpio0Val === 1 ) ? 0 : 1; // 条件 (三項) 演算子 - await gpioPort0.write(gpio0Val); - msg.innerHTML= gpio0Val ; - await sleep(1000); - } +async function LEDblink() { + var gpio0Val = 0; + while (blinkEnable) { + gpio0Val = gpio0Val === 1 ? 0 : 1; // 条件 (三項) 演算子 + await gpioPort0.write(gpio0Val); + await gpioPort1.write(!gpio0Val); + msg.innerHTML = gpio0Val; + await sleep(10000); + } } -