How to use more than one servo for AdvancedServo 8 motor

Supporting Browser-based Javascript and Node.js
Post Reply
jojoba
Fresh meat
Posts: 2
Joined: Wed Feb 13, 2019 5:22 pm
Contact:

How to use more than one servo for AdvancedServo 8 motor

Post by jojoba »

Greetings!

Great products folks. Thank you!

I am using the phidgets advanced servo 8 motor board. I have two servos hooked up to it. I am able to successfully control only one motor. But I am curious how one controls MULTIPLE servos. Here is my javascript code below. I feel like I am close and appreciate any help you might offer.

Best,
jojoba

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.setChannel(0);
            this.rcServo_0.onAttach = ch => {
                console.log(ch + ' attached');
                this.rcServo_0.setTargetPosition(this.SERVO_INITIAL_POSITION);
                this.rcServo_0.setEngaged(1);
            };
            
            
            this.rcServo_1 = new phidget22.RCServo();
            this.rcServo_1.setChannel(1);
            this.rcServo_1.onAttach = ch => {
                console.log(ch + ' attached');
                this.rcServo_1.setTargetPosition(this.SERVO_INITIAL_POSITION);
                this.rcServo_1.setEngaged(1);
            };
        });
Post Reply

Who is online

Users browsing this forum: No registered users and 2 guests