https://news.mynavi.jp/techplus/article/makeprogram-30/
---------------receiver :: obniz ---------------
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<script src="https://obniz.io/js/jquery-3.2.1.min.js"></script>
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.1/css/bootstrap.min.css" integrity="sha384-WskhaSGFgHYWDcbwN70/dfYBj47jz9qbsMId/iRN3ewGhXQFZCSftd1LZCfmhktB" crossorigin="anonymous">
<script src="https://unpkg.com/obniz@latest/obniz.js" crossorigin="anonymous"></script>
<script src="https://unpkg.com/obniz-parts-kits@0.11.2/iothome/index.js"></script>
<script src="https://unpkg.com/obniz-parts-kits@0.11.2/ai/index.js"></script>
<script src="https://unpkg.com/obniz-parts-kits@0.11.2/airobot/index.js"></script>
<script src="https://unpkg.com/obniz-parts-kits@0.11.2/ui/index.js"></script>
<script src="https://unpkg.com/obniz-parts-kits@0.11.2/ai/opencv3.4/opencv.js"></script>
<script src="https://cdn.jsdelivr.net/npm/@tensorflow/tfjs@0.13.5"> </script>
<script src="https://cdn.jsdelivr.net/npm/@tensorflow-models/mobilenet@0.2.2"> </script>
</head>
<body>
Micro:bit Serial
<div id="OBNIZ_OUTPUT"></div><br/>
<script>
(async function(){
var obniz;
obniz = new Obniz('5312-1232');
await obniz.connectWait();
obniz.io2.output(false);
obniz.uart0.start({rx:0, tx:1});
obniz.uart0.onreceive=function(data,text){
console.log(data[0]+":"+data[1]+">"+text);
}
})();
</script>
</body>
</html>
------------------sender :: microbit --------
serial.redirect(
SerialPin.P0,
SerialPin.P1,
BaudRate.BaudRate115200
)
basic.forever(function () {
serial.writeNumber(input.lightLevel())
basic.pause(1000)
})
----------------- sender :: obniz ------------------------------------
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<script src="https://obniz.io/js/jquery-3.2.1.min.js"></script>
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.1/css/bootstrap.min.css" integrity="sha384-WskhaSGFgHYWDcbwN70/dfYBj47jz9qbsMId/iRN3ewGhXQFZCSftd1LZCfmhktB" crossorigin="anonymous">
<script src="https://unpkg.com/obniz@latest/obniz.js" crossorigin="anonymous"></script>
<script src="https://unpkg.com/obniz-parts-kits@0.11.2/iothome/index.js"></script>
<script src="https://unpkg.com/obniz-parts-kits@0.11.2/ai/index.js"></script>
<script src="https://unpkg.com/obniz-parts-kits@0.11.2/airobot/index.js"></script>
<script src="https://unpkg.com/obniz-parts-kits@0.11.2/ui/index.js"></script>
<script src="https://unpkg.com/obniz-parts-kits@0.11.2/ai/opencv3.4/opencv.js"></script>
<script src="https://cdn.jsdelivr.net/npm/@tensorflow/tfjs@0.13.5"> </script>
<script src="https://cdn.jsdelivr.net/npm/@tensorflow-models/mobilenet@0.2.2"> </script>
</head>
<body>
Micro:bit Serial
<div id="OBNIZ_OUTPUT"></div><br/>
<script>
(async function(){
var obniz;
obniz = new Obniz('5312-1232');
await obniz.connectWait();
obniz.io2.output(false);
obniz.uart0.start({rx:0, tx:1});
obniz.uart0.send("microbit+obniz");
})();
</script>
</body>
</html>
------------------------- receiver:: microbit --------------------------------
serial.redirect(
SerialPin.P0,
SerialPin.P1,
BaudRate.BaudRate115200
)
basic.forever(function () {
basic.showString(serial.readString() )
})
0 件のコメント:
コメントを投稿