Just a dabbler here and despite endless research I’m really struggling with making Javascript repeat this code block over and over a set number of times. It's for a Phidget rel1000_0 switch/relay (with a timer for duration).
I can't find a working method to make the process repeat itself.
Below is the working code example, with explanatory notes, from the website. No matter what looping method I cut and paste in, and no matter where it’s placed, it’s not working. Any help VERY welcome! Thanks.
Code:
var phidget22 = require('phidget22');
function runExample() {
//Create your Phidget channels
var digitalOutput0 = new phidget22.DigitalOutput();
//Set addressing parameters to specify which channel to open (if any)
digitalOutput0.setHubPort(2);
digitalOutput0.setDeviceSerialNumber(606877);
//Assign any event handlers you need before calling open so that no events are missed.
//Open your Phidgets and wait for attachment
digitalOutput0.open(5000).then(function() {
//Do stuff with your Phidgets here or in your event handlers.
digitalOutput0.setDutyCycle(1);
setTimeout(function () {
//Close your Phidgets once the program is done.
digitalOutput0.close();
process.exit(0);
}, 3000);
});
}