<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@latest/obniz.js"></script>
</head>
<body>
<h2 class="text-center" style="margin:40px">motor contol</h2>
<div id="onoff-buttons" class="text-center">
<button id="front" type="button" class="btn btn-primary">front</button>
<button id="back" type="button" class="btn btn-secondary">back</button ><br />
<div id="obniz-debug"></div>
<script>
var obniz = new Obniz("4998-4317");
obniz.onconnect = async function () {
var motor = obniz.wired("DCMotor", {forward:10, back:11});
$('#front').click(function () {
motor.forward();
setTimeout(function(){
motor.stop();
}, 1000);
});
$('#back').click(function () {
motor.reverse();
setTimeout(function(){
motor.stop();
}, 1000);
});
}
</script>
</body>
</html>
---------------------------------------------------------------------------------------
https://take6shin-tech-diary.com/obniz-steppingmotor/ ステッピングモータ単独でつかう方法
アルディーノとちがい、付属のULN2003ANトランジスタアレイ応用モジュール不要
0 件のコメント:
コメントを投稿