Dial Controls Servo

Control servo motor in accordance with potention meter.

Connect

Let's use two parts this time.
Connect the potention meter and the servo motor to an obniz.

The potention meter should be connected to 0,1,2 and servo motor to 3,4,5.

Program

The program is simple as it is a combination of what we have seen already.
This is the full code.

<!-- HTML Example -->
<html>
<head>
  <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@2.4.0/obniz.js"></script>
</head>
<body>

<div id="obniz-debug"></div>
<h1>Dial To Servo</h1>

<script>
var obniz = new Obniz("OBNIZ_ID_HERE");
obniz.onconnect = async function () {
  var meter = obniz.wired("Potentiometer", {pin0:0, pin1:1, pin2:2});
  var servo = obniz.wired("ServoMotor", {gnd:3, vcc:4, signal:5});
  meter.onchange = function(position) {
    servo.angle(position * 180);
  };
}
</script>
</body>
</html>

After opening the HTML, the servo motor will move following the potention meter.
Perhaps the servo motor will rotate towards the opposite direction from the potention meter.
How would you change the direction of rotation? Please give it a thought.



Next : Two obniz integration

You will Get in Few Days

Circuit for Starter “obniz Board” is available on Amazon and other online stores.
You can get it at below

Our products and resellers

Forum

Visit our developer’s forum to discuss and discover technologies.

Forum

Contact

Feel free to contact out support and technical team.

Contact us