Phidget led 64 - Setting a channel

Supporting Browser-based Javascript and Node.js
Fresh meat
Posts: 2
Joined: Mon Oct 29, 2018 7:29 am

Phidget led 64 - Setting a channel

Postby gallantoss » Mon Nov 05, 2018 6:34 pm

How do I set more than one channel in javascript, using the phidget led 64?

sensor = new jPhidget22.DigitalOutput();

for(let i = 0 ; i <=1 ; i++){



This is what I tried so far...

Thank you!

User avatar
Site Admin
Posts: 658
Joined: Fri Oct 28, 2011 12:17 pm

Re: Phidget led 64 - Setting a channel

Postby mparadis » Tue Nov 06, 2018 9:08 am

You need to create a separate DigitalOutput object for each channel you want to have open. So, you could do something like this:

Code: Select all

sensor0 = new jPhidget22.DigitalOutput();
sensor1 = new jPhidget22.DigitalOutput();

Of course, this will get tedious quickly if you want to do it for all 64 channels, so you might want to use an array and a loop instead:

Code: Select all

var leds = [];

for(i = 0; i < 64; i++) {

   ch = new jPhidget22.DigitalOutput();

From then on you can access the digital output with leds[i]. You'll have to create a similar for loop when you open, close, or set any property that you want on all 64 outputs.

Return to “Javascript”

Who is online

Users browsing this forum: No registered users and 1 guest