Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
board.on("ready", function() {
// Log
console.log("Connected to Johnny-Five!");
// Speed can be anything from 0 to 255
var SPEED = 130;
var PAN = 95;
var TILT = 115;
var command = "";
var panState = PAN;
var tiltState = TILT;
// Initialise the motors and servos
var leftMotor = new five.Motor([11, 8]);
var rightMotor = new five.Motor([5, 7]);
//var leftMotor = new five.Motor([10, 8]);
//var rightMotor = new five.Motor([9, 7]);
var tiltServo = new five.Servo({ pin: 2, range: [ 75, 155 ], startAt: 115 });
var panServo = new five.Servo({ pin: 4, range: [ 45, 145 ], startAt: 95 });
// Set up REPL (used mainly for demo and testing purposes)
board.repl.inject({
left: leftMotor,
right: rightMotor,
tilt: tiltServo,
pan: panServo
});
// Set up MQTT Client
board.on("ready", function() {
// Log
console.log("Connected to Johnny-Five!");
// Speed can be anything from 0 to 255
var SPEED = 130;
var PAN = 95;
var TILT = 115;
var command = "";
var panState = PAN;
var tiltState = TILT;
// Initialise the motors and servos
var leftMotor = new five.Motor([11, 8]);
var rightMotor = new five.Motor([5, 7]);
//var leftMotor = new five.Motor([10, 8]);
//var rightMotor = new five.Motor([9, 7]);
var tiltServo = new five.Servo({ pin: 2, range: [ 75, 155 ], startAt: 115 });
var panServo = new five.Servo({ pin: 4, range: [ 45, 145 ], startAt: 95 });
// Set up REPL (used mainly for demo and testing purposes)
board.repl.inject({
left: leftMotor,
right: rightMotor,
tilt: tiltServo,
pan: panServo
});
// Set up MQTT Client
//var options = { host: "test.mosca.io", port: "1883" }; //backup
board.on('ready', function onReady() {
const motorA = new five.Motor({
pins: {
pwm: 6,
dir: 7,
cdir: 8
}
}),
motorB = new five.Motor({
pins: {
pwm: 11,
dir: 10,
cdir: 9
}
});
// 100% velocidad al frente en los dos motores
motorA.forward(255);
motorB.forward(255);
setTimeout(() => {
// 100% velocidad marcha atras en los dos motores
motorA.reverse(255);
motorB.reverse(255);
}, 5000);
board.on("ready", () => {
const spdt = new Switch("a0");
const throttle = new Sensor("b0");
// See the comments below for more information about
// the pins shown in this pin array argument.
const motor = new Motor([ "a5", "a4", "a3" ]);
spdt.on("open", () => {
motor.stop().forward(motor.speed());
});
spdt.on("close", () => {
motor.stop().reverse(motor.speed());
});
throttle.on("change", () => {
motor.speed(throttle.value >> 2);
});
});
/* @markdown
board.on("ready", function(err) {
if (err){
console.log(err);
return;
}
l_motor = new five.Motor({pins: {pwm: 6, dir: 7}});
r_motor = new five.Motor({pins: {pwm: 5, dir: 4}});
console.info("Board connected. Robot set up. LRUD to control");
});
board.on('ready', function () {
var motor = new five.Motor({
pin: 9
});
motor.on('start', function () {
board.wait(2000, function () {
motor.stop();
});
});
motor.on('stop', function () {
board.wait(1000, function () {
motor.start(200);
});
});
motor.start(200);
board.on('ready', function () {
var motor = new five.Motor(9)
motor.on('start', function () {
board.wait(2000, function () {
motor.stop()
})
})
motor.on('stop', function () {
board.wait(1000, function () {
motor.start(200)
})
})
motor.start(200)
})
board.on("ready", function(err) {
if (err){
console.log(err);
return;
}
console.info("Board connected. Robot set up");
motor_r = new five.Motor({
pins: {
pwm: 9,
dir: 8,
},
invertPWM: true,
});
motor_l = new five.Motor({
pins: {
pwm: 6,
dir: 7,
},
invertPWM: true,
});
led = new five.Led(11);
board.on("ready", function() {
var servo = new five.Motor(5);
servo.start();
this.repl.inject({
servo: servo
});
});
board.on("ready", function() {
var speed = 125;
//var piezo = new five.Piezo(3);
motor1 = new five.Motor([10, 8]);
motor2 = new five.Motor([9, 7]);
board.repl.inject({
lmotor: motor1,
rmotor: motor2,
});
require('net').createServer(function (socket) {
socket.on('data', function (data) {
switch ( data.toString().trim() ){
case 'go':
motor1.rev( speed );
motor2.rev( speed );
break;