obniz developer team
Published

Remote Harisen Control by Linking Two obnizes

Make a system by linking two obnizes that if you turn a dial (Potentiometer), you can control the harisen remotely.

BeginnerFull instructions provided3 hours185
Remote Harisen Control by Linking Two obnizes

Things used in this project

Hardware components

obniz
Cambrian Robotics obniz
×1
SG90 Micro-servo motor
SG90 Micro-servo motor
×1
Rotary potentiometer (generic)
Rotary potentiometer (generic)
×1

Story

Read more

Code

source code

HTML
<!DOCTYPE html>
<html>
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1" />
    <script
      src="https://unpkg.com/obniz@3.x/obniz.js"
      crossorigin="anonymous"
    ></script>
    <script
      src="https://code.jquery.com/jquery-3.4.1.js"
      integrity="sha256-WpOohJOqMqqyKL9FccASB9O0KwACQJpFTUBLTYOVvVU="
      crossorigin="anonymous"
    ></script>
    <title>Remote Harisen Control</title>
  </head>

  <body>
    <script>
      $(() => {
        let potentObniz = new Obniz("OBNIZ_ID_HERE");
      
        potentObniz.onconnect = async () => {
          let motorObniz = new Obniz("OBNIZ_ID_HERE");
          motorObniz.onconnect = async () => {
            let meter = potentObniz.wired("Potentiometer", {
              pin0: 0,
              pin1: 1,
              pin2: 2
            });
            let servo = motorObniz.wired("ServoMotor", {
              signal: 0,
              vcc: 1,
              gnd: 2
            });
      
            meter.onchange = async (position) => {
              servo.angle(position * 180);
            };
          };
        };
      
        potentObniz.onclose = async () => {
          if (motorObniz !== null && motorObniz !== undefined) {
            await motorObniz.close();
          }
        };
      });

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

Credits

obniz developer team
80 projects • 35 followers
Development board "obniz" is controlled via the internet.
Contact

Comments

Please log in or sign up to comment.