1065 Motor control reversing
Posted: Tue Mar 01, 2022 6:17 pm
I'm trying to update some Phidgets 21 code to 22.
Trying to run a motor one direction, wait 5 seconds and run back the other way. 1065 PhidgetMotorControl 1-motor
I just can't figure it out.
Can someone please help?
Marsha
Trying to run a motor one direction, wait 5 seconds and run back the other way. 1065 PhidgetMotorControl 1-motor
I just can't figure it out.
Can someone please help?
Marsha
Code: Select all
var phidget22 = require('phidget22');
function runExample() {
var dcMotor0 = new phidget22.DCMotor();
dcMotor0.open(5000).then(function() {
dcMotor0.setTargetVelocity(1);
setTimeout(function () {
dcMotor0.close();
process.exit(0);
}, 5000);
});
dcMotor0.open(5000).then(function() {
dcMotor0.setTargetVelocity(-1);
setTimeout(function () {
dcMotor0.close();
process.exit(0);
}, 5000);
});
}
var conn = new phidget22.Connection(5661, 'localhost');
conn.connect().then(runExample);