Control servo motor with an obniz dev board.
It is JavaScript dev board, and can use in browser.
Step 1: Setting Up obnizTo set up obniz, all you need to do is to follow three steps.
- Connect obniz to WiFi.
- Connect devices like LED or motors to obniz.
- Scan QR code of obniz and start programming. You do not need to install any software.
- Connect servo and usb to obniz.
- Connect usb fan to usb.
obniz can output max 5V1A, motor can be connect directly.
Step 3: SOFTWAREThe code is one HTML file.
It use navigator.getUserMedia
for get camera data, and detect face with OpenCV.
When detect face, it send servo control commands to obniz.
This is only code for control servo.
<script src="https://unpkg.com/obniz@1.2.1/obniz.js"></script>
<script>
let obniz = new Obniz("17804573");
let servo;obniz.onconnect = async () => {
obniz.display.print("ready");
var usb = obniz.wired("USB" , {gnd:11, vcc:8} );
usb.on();
servo = obniz.wired("ServoMotor", {signal:0,vcc:1, gnd:2});
}
if(/* when detect face */){
servo.angle(xPos * 180 / 320);
}
</script>
What Is obniz?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.
obniz has 12 IO and WiFi-BLE module. It can be controlled through the APIs – REST or WebSocket API – on obniz cloud. Not only simple IO on/off but also UART, I2C, BLE etc can be used by remotely controlling obniz via internet. All you need to do to connect obniz is to input unique ID by scanning QR code. Complicated processes are done by obniz and its cloud. You can just start programming in HTML, browser and circuit have already been integrated. If you write a program to collect sensor values, you can make a chart of the values easily.
In terms of hardware, every IO can drive up to 1A with overcorrect protection, therefore high current demanding devices such as motors can be directly connected to obniz IO. GPIO and AD can be used on every IO. UART, SPI etc peripherals can be assigned to every IO.Even output voltage 3v/5v can be changed by software. Most electrical parts can be connected directly. Embedded parts such as switch, OLED display, and BLE are ready for use on program.
Comments