neorobohon が 2021年05月19日14時51分24秒 に編集
初版
タイトルの変更
模型レーシング用ラップカウンタ obniz(1Y) Rev.0
タグの変更
フォトリフレクタ
メイン画像の変更
本文の変更
部品 マイコン obniz(1Y) 競技車両検出 フォトリフレクタ LBR-127HLD 120Ωx1 1.5kΩ シグナル 赤色LED x3 560Ωx3 ソースコード(ブロックプログラム) $("#bploading").text("RUNNING..."); (async function(){ var obniz01, count, led011, ir011, led012, led013, label; /** * この関数の説明… */ async function f_def_obniz01_led() { led011 = obniz01.wired("LED",{"anode":4, "cathode":7}); led012 = obniz01.wired("LED",{"anode":5, "cathode":7}); led013 = obniz01.wired("LED",{"anode":6, "cathode":7}); } /** * この関数の説明… */ async function f_obniz01_countdown() { led011.on(); led012.on(); led013.on(); await _ai.playAudio(440,1 * 500); await obniz01.wait(100); await obniz01.wait(450); led011.off(); await _ai.playAudio(440,1 * 500); await obniz01.wait(100); await obniz01.wait(450); led012.off(); await _ai.playAudio(440,1 * 500); await obniz01.wait(100); await obniz01.wait(450); led013.off(); await _ai.playAudio(1500,1 * 500); await obniz01.wait(450); led013.off(); } /** * この関数の説明… */ async function f_def_obniz01_detector() { ir011 = obniz01.wired("LED",{"anode":0, "cathode":1}); } obniz01 = new Obniz('2757-2457'); await obniz01.connectWait(); await f_def_obniz01_led(); await f_obniz01_countdown(); await f_def_obniz01_detector(); ir011.on(); count = 0; for (var count2 = 0; count2 < 300; count2++) { await ObnizUI.Util.wait(0); if ((await obniz01.ad2.getWait()) < 4) { count = (typeof count == 'number' ? count : 0) + 1; } } label = new ObnizUI.Label('label'); label.setText(('周回数' + String(count))); await _ai.say(('周回数' + String(count))); ir011.off(); count; })(); ![作品画像](https://camo.elchika.com/3cb8ad6e9cca68b33eb5f2abefe6344773154051/687474703a2f2f73746f726167652e676f6f676c65617069732e636f6d2f656c6368696b612f76312f757365722f35386661323733622d393261662d343864372d623561642d3865323061343364353566312f35333562616665622d353430372d343561642d613530342d343766363332306332336339/) ![ブロックプログラム](https://camo.elchika.com/96f8a461d98a452f3b674e305b43a5062a163e75/687474703a2f2f73746f726167652e676f6f676c65617069732e636f6d2f656c6368696b612f76312f757365722f35386661323733622d393261662d343864372d623561642d3865323061343364353566312f35346566656630642d613666622d343439382d383635392d383333653866316261323833/) ![回路図](https://camo.elchika.com/2acf5aaeb243a0ecf8d7c89039c469c214ba950e/687474703a2f2f73746f726167652e676f6f676c65617069732e636f6d2f656c6368696b612f76312f757365722f35386661323733622d393261662d343864372d623561642d3865323061343364353566312f33616230316162352d613263392d343835612d626565352d326437643930613361623663/) [動作](https://www.youtube.com/watch?v=ZTpiqH_qyAg)