I love Phidgets!
I am attempting to control more than one servo via the AdvancedServoControl 8-motor board and am close, but coming up short. I've pasted my code below. Do you happen to have any guesses as to why I can't control more than one servo? Thank you kindly.
Best,
matthew
Code: Select all
        var phidget22 = require('phidget22');
        var serverConnection = new phidget22.Connection(
            this.SERVER_PORT,
            this.PHIDGETS_SERVER_HOSTNAME,
            {
                name: 'Server Connection',
                passwd: '' 
            }
        );
        serverConnection.connect().then(() => {
            console.log('connected to phidgets server');
            this.rcServo_0 = new phidget22.RCServo();
            this.rcServo_0.onAttach = ch => {
                console.log(ch + ' attached');
                this.rcServo_0.setChannel(0);
                this.rcServo_0.setTargetPosition(90);
                this.rcServo_0.setEngaged(1);
            };
        
            this.rcServo_0.open().then((ch) => {
                console.log('channel open');
                //console.log(this.rcServo_0);
            }).catch(function (err) {
                console.log('failed to open the channel:' + err);
            });
            this.rcServo_1 = new phidget22.RCServo();
            this.rcServo_1.onAttach = ch => {
                console.log(ch + ' attached');
                this.rcServo_1.setChannel(1);
                this.rcServo_1.setTargetPosition(90);
                this.rcServo_1.setEngaged(1);
            };
        
            this.rcServo_1.open().then((ch) => {
                console.log('channel open');
                //console.log(this.rcServo_0);
            }).catch(function (err) {
                console.log('failed to open the channel:' + err);
            });
        });