2024年6月1日土曜日

obniz IoT CAR

 
2018年に製作したobniz Carについて記事にしました。
●obnizのPinにモータを直接接続することにより、パソコン・スマホからWiFiによる遠隔操作できます。
●AI Robot Kit【https://docs.obniz.com/ja/guides/ai-robot-kit/】を参考にobniz CarにAI機能を追加することができます。
●obniz・モータの共通電源はIoT機器対応 モバイルバッテリーを使用しました。





レガシープログラム
https://console.obniz.com/ja/repository】2018年製作したプログラム




obniz OLED
プログラムを実行するとOLEDに[PIN ASSIGN]ピン割当が表示される。
PIN8 9    →モータ1
PIN10 11   →モータ2












obniz CAR操作画面


パソコン・スマホ画面
●走行操作ボタン
●[A][C][G][I]→OLEDに表示



プログラム
<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>
  <script src="https://unpkg.com/obniz@1.13.1/obniz.js" crossorigin="anonymous"></script>
</head>
<body>

<div id="obniz-debug"></div>
<h3>ROBOT</h3>  
<button id="a" style="WIDTH: 100px; HEIGHT: 100px">A</button>
<button id="go" style="WIDTH: 100px; HEIGHT: 100px">GO</button>
<button id="c" style="WIDTH: 100px; HEIGHT: 100px">C</button>
 <h1></h1> 
<button id="left" style="WIDTH: 100px; HEIGHT: 100px">LEFT</button>
<button id="stop" style="WIDTH: 100px; HEIGHT: 100px">STOP</button>
<button id="right" style="WIDTH: 100px; HEIGHT: 100px">RIGHT</button>
<h1></h1> 
<button id="g" style="WIDTH: 100px; HEIGHT: 100px">G</button>
<button id="back" style="WIDTH: 100px; HEIGHT: 100px">BACK</button>
<button id="i" style="WIDTH: 100px; HEIGHT: 100px">I</button>

<script>
var obniz = new Obniz("9406-XXXX");
obniz.onconnect = async function () { 
  
var Lmotor = obniz.wired("DCMotor", {forward:8, back:9});
var Rmotor = obniz.wired("DCMotor", {forward:10, back:11});  
Rmotor.power(30);
Lmotor.power(30);
  
  $("#a").on("click",function(){      
      obniz.display.clear();
      obniz.display.pos(50,10);
      obniz.display.font(null,40)
      obniz.display.print("A");
    
  });
  
  $("#go").on("click",function(){       
      Rmotor.forward();      
      Lmotor.forward();
   
  });
  
  $("#c").on("click",function(){      
      obniz.display.clear();
      obniz.display.pos(50,10);
      obniz.display.font(null,40)
      obniz.display.print("C");    
     
  });
  
  $("#left").on("click",function(){       
      Rmotor.forward();      
      Lmotor.reverse();          
  });
  
  $("#stop").on("click",function(){       
      Rmotor.stop();      
      Lmotor.stop();     
    
  });
  
  $("#right").on("click",function(){       
      Rmotor.reverse();         
      Lmotor.forward();     
    
  });
  
  $("#g").on("click",function(){      
      obniz.display.clear();  
      obniz.display.pos(50,10);
      obniz.display.font(null,40)
      obniz.display.print("G");
    
  });
  
  $("#back").on("click",function(){      
      Rmotor.reverse();      
      Lmotor.reverse();
      
    
  });
  
  $("#i").on("click",function(){      
      obniz.display.clear();
      obniz.display.pos(50,10);
      obniz.display.font(null,40)
      obniz.display.print("I");
    
  });  
};

</script>
</body>
</html>

0 件のコメント:

コメントを投稿

FST3253 - 直交ミキサ製作

アマゾンの口コミ(SDRトランシーバーに使用出来る)を見てFST3253MTCとピッチ変換基板を購入、FST3253 直交ミキサ基板を製作してPi Pico Rxで受信確認できました。  ●Pi Pico Rx  【 https://101-things.readthedocs....