Vibrobot made with obniz


The Vibrobot can now operate from anywhere in the world.

A Vibrobot is a robot to which brushes are attached instead of tires, and when vibrates the brushes, it proceeds in a specific direction due to the asymmetry of the coat.
This robot can go straight ahead, turn right, and turn left by PWM controlling two vibration motors and operating the left and right brushes respectively.
In addition, a distance sensor is mounted on the front and you can confirm in real time on the screen of the smartphone whether there is an obstacle ahead.


Operation Method

Depending on the distance to the obstacle ahead, the color of the area on the screen changes. It gets green when the obstacle is far, and it gets red when the obstacle is near.
In Manual mode, you can freely control the robot to go straight ahead, turn right and left by adjusting the strength of left and right vibrations with the slider in the Control area on ​​the screen. It may be interesting to control the robot from where you can’t see it but seeing only the color of the screen.
If you set Power to Low, Middle, or High, it will be in Auto mode, usually continue going straight ahead and automatically turn right when approaching to an obstacle, which allows it to keep moving semipermanently.

When you make this, it is necessary to form a habit such that the tips of the brushes turn diagonally backward.
You can also manipulate many obniz at the same time from one smartphone, so if you make a lot of such robots and move them at the same time, they may work interestingly with each other.


<!-- HTML Example -->
<!DOCTYPE html>
<html lang="en">
    <meta charset="utf-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <script src=""></script>
    <script src=""></script>
    <script src=""></script>
    <style type="text/css">
        css {
            touch-action: none;

        input.controller {
            margin-top: 25%;
            -webkit-transform: rotate(270deg);
            -moz-transform: rotate(270deg);
            -o-transform: rotate(270deg);
            transform: rotate(270deg);
            -webkit-border-radius: 24px;
            -moz-border-radius: 24px;
            border-radius: 24px;

        input.controller {
            -webkit-appearance: none;
            width: 90%;
            background: #eee;
            box-shadow: 0 0 10px #666;
            border-radius: 10px;

        input.controller::-webkit-slider-thumb {
            -webkit-appearance: none;
            background: #333;
            width: 50px;
            height: 50px;
            border-radius: 50%;

        input.controller::-webkit-slider-thumb:hover {
            background: #999;

        input.controller::-webkit-slider-thumb:active {
            background: #fefefe;

        .box {
            display: table-cell;

    <div id="obniz-debug"></div>
    <div id="mode-print"></div>
    <div id="dist-print"></div>
    <div id="print" style="height:100px;"></div>

    <p class="switch">
        <br />
            <input type="radio" name="power" id="" value=0 onchange="changemode(this.value)">Manual</label>
            <input type="radio" name="power" value="60" onchange="changemode(this.value)">Low</label>
            <input type="radio" name="power" value="80" onchange="changemode(this.value)">Middle</label>
            <input type="radio" name="power" value="100" onchange="changemode(this.value)">High</label>

    <div class="sliders">
        <div class="box">
            <label for="slider_pwm1">Left</label>
            <input id="slider_pwm1" type="range" class="controller" min="0" max="100" value="0" />
        <div class="box">
            <label for="slider_pwm2">Right</label>
            <input id="slider_pwm2" type="range" class="controller" min="0" max="100" value="0" />

        var obniz = new Obniz("OBNIZ_ID_HERE");
        var mode = 0, pwm, pwm2;
        var power = 0;

        obniz.onconnect = async function () {
            var sensor = obniz.wired("GP2Y0A21YK0F", { vcc: 0, gnd: 1, signal: 2 })
            sensor.start(function (distance) {
                $("#dist-print").text("distance: " + distance + " mm");

                var color_scale = d3.scaleLinear()
                    .domain([0, 200, 400])
                    .range(['red', 'yellow', 'lime'])

                if (mode == 1) {
                    if (distance < 150) {
                    } else {
                } else {

            pwm = obniz.getFreePwm();
            pwm.start({ io: 7 });

            $("#slider_pwm1").on('input', function () {

            pwm2 = obniz.getFreePwm();
            pwm2.start({ io: 5 });

            $("#slider_pwm2").on('input', function () {

        obniz.onclose = async function () {

        function changemode(_power) {
            power = _power;
            if (_power != 0) {
                mode = 1;
                $("#slider_pwm1").prop('disabled', true);;
                $("#slider_pwm2").prop('disabled', true);;
            } else {
                mode = 0;
                $("#slider_pwm1").prop('disabled', false);
                $("#slider_pwm2").prop('disabled', false);

        function changeBoxColor(newColor) {
            document.getElementById('print').style.backgroundColor = newColor;


Run Now

The html will be opened to run a program.