Document

obniz Hardware and cloud specifications.

DCMotor

Common Brushed DC Motor which moves when connected to +/- and reverse when connected to other side.

wire({forward, back})

connect two wire to an obniz and set io number to forward,back.
If you connect to io 0 and 1, then write a program like a below.

photo of DCMotor

// Javascript Example
var motor = obniz.wired("DCMotor",  {forward:0, back:1});
motor.power(50);
motor.forward();

forward()

start moving forward.

// Javascript Example
var motor = obniz.wired("DCMotor", {forward:0, back:1});

motor.forward();

reverse()

start moving to back.

// Javascript Example
var motor = obniz.wired("DCMotor", {forward:0, back:1});

motor.reverse();

stop()

stop a motor.

// Javascript Example
var motor = obniz.wired("DCMotor", {forward:0, back:1});

motor.forward();
setTimeout(function(){
  motor.stop();
}, 1000);

move(boolean)

move a motor regard provided value.

// Javascript Example
var motor = obniz.wired("DCMotor", {forward:0, back:1});

motor.move(true); // = motor.forward();

power(float)

set a motor power.

default is 30.

power must be within 0~100.

// Javascript Example
var motor = obniz.wired("DCMotor", {forward:0, back:1});

motor.power(80);
motor.move(true);


Found at :