I have the code I am playing with:
Code: Select all
let vs1_13 = new jFive.Switch(12);
  vs1_13.on('open', function () {
    
    console.log('vs1_13 on');
    //LED on
    LEDBoardObj.board1.chInstance0.open().then(function () {
      // code to execute after open succeeds
      console.log('Utgång 0 - Öpppen');
      LEDBoardObj.board1.chInstance0.setDutyCycle(dimValue);  
    }).catch(function (err) {
      // code to execute if open fails
      console.log('Utgång 0 - Ej öppen');  
    });
    // Status setting
    
    // FlightSim setting
  });
  vs1_13.on('close', function () {
    console.log('vs1_13 off');
    //LED on
    LEDBoardObj.board1.chInstance1.open().then(function () {
      // code to execute after open succeeds
      console.log('Utgång 0 - Öppen');
      LEDBoardObj.board1.chInstance1.setDutyCycle(dimValue);  
    }).catch(function (err) {
      // code to execute if open fails
      console.log('Utgång 0 - Ej öppen');  
    });
    // Status setting
    
    // FlightSim setting
  });
So when swith on at my swith the led it should be light and should be closed when the with is off. I have one green led and one red. My goal is switch = on, led green is on. When switch = off a red led is on and the green led is off. Like a blinking light but with two leds

I have read about a close function but where am I need placing it in both the vs1_13.on('open'/'close', functions ... to getting it to work?
If you are going to need more info I can share it, no problem!
Best regards Fredrik
