Make a system by linking two obnizes that if you turn a dial (Potentiometer), you can control the harisen remotely. You can link two obnizes by one program easily.
Materials- obniz Board x 2
- Servo Motor
- Potentiometer
- harisen (folded paper fan for the comedy)
- disposable chopsticks
- (dial to make control easier)
Hardware connection
- the side of the remote control
Connect a Potentiometer to an obniz Board like the table and the image below by referring to Potentiometer Library. You can replace pin0 and pin2. (The potentiometer turns backward.)
obniz (the side of the remote control) Potentiometer 0 Vcc 1 signal (middle) 2 GND
- the side of harisen
Connect a Servo Motor to an obniz Board like the table and the image below by referring to Servo Motor Library.
the side of harisen Servo Motor 0 signal 1 Vcc 2 GND
Body
- the side of the remote control
Cover the Potentiometer with a dial to make control easier. Hook the wire so that when you turn the dial, the Potentiometer turns with it.
- the side of harisen
Put the harisen between the disposable chopsticks and fix it on the Servo Hone.
Software
The program links two obnizes. After waiting for connecting the obniz of the side of the remote control, make the obniz of the side of harisen connected in this part below.
Please read Two obniz integration | Startup Lessons for JavaScript | obniz for details.
let potentObniz = new Obniz('OBNIZ_ID_HERE');
potentObniz.onconnect = async () => {
let motorObniz = new Obniz('OBNIZ_ID_HERE');
motorObniz.onconnect = async () => {
...
}
}
}
Also, if detect changes of potentiometer value, the Servo Motor angle will change according to its value.
Please read Potentiometer Library for details.
meter.onchange = async (position) => {
servo.angle(position * 180);
};
Program<!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>
What is obniz?Before we get into the project, let's look into obniz.
Here → obniz for DIY electronics
obniz is a cloud-connected IoT development board. You can program on the web browser of any smartphone or computer and the command is sent to obniz through the internet via obniz cloud. By connecting the obniz to the cloud through wifi, users can remotely control devices that are physically connected to obniz.
Thanks to this cloud based approach, you can program with Python, Javascript, or other languages you prefer and control hardware directly. You don't need to integrate firmware into the device side. Recording and analyzing data is also easy with obniz cloud service.
Want to control hardware things with your current Python or Javascript skill? Want to start IoT project but don't know where to start? Want to learn programming with languages you prefer?
obniz will help you broaden your viewpoint and develop both your SW and HW skills.
For more information, please visit our official website → Official Website
Where to get obniz board? → Amazon /Official Store
Comments
Please log in or sign up to comment.