Page 1 of 1

Problem with PiGPIO in javascript

Posted: Sun Jun 10, 2018 6:11 am
by feededandrea
Hi to all. I was trying to make PWM output for a Led with PiGIO on a ".js" file. So I have this code that works perfect:

Code: Select all

var Gpio = require('pigpio').Gpio,
  led = new Gpio(17, {mode: Gpio.OUTPUT,edge: Gpio.EITHER_EDGE});
  led.pwmWrite(value);

<value is between 0 and 255>

But if I want to have multiple outputs, like multiple Leds, I try this:

Code: Select all

var Gpio = require('pigpio').Gpio,
  led1 = new Gpio(17, {mode: Gpio.OUTPUT,edge: Gpio.EITHER_EDGE});
  led1.pwmWrite(value1);
  
  led2 = new Gpio(10, {mode: Gpio.OUTPUT,edge: Gpio.EITHER_EDGE});
  led2.pwmWrite(value2);
This for some reason doesn't work. Its like the Led1 works perfect, but the second one, Led2 doesn't do anything, just keeps turned off.

I wish someone could help me, thanks in advance!

Re: Problem with PiGPIO in javascript

Posted: Mon Jun 11, 2018 10:12 am
by joan
I can't help with javascript.

I can offer a diagnostic suggestion.

On the Pi see if you can trace what pigpio is getting in the way of commands.

In a Pi terminal

# turn on debugs
pigs csi 6

#look at debug info
cat /dev/pigerr &

Then run your javascript.

Re: Problem with PiGPIO in javascript

Posted: Mon Jun 11, 2018 10:14 am
by Heater
Have you tried removing the led1 code and just driving led2 on it own?

Re: Problem with PiGPIO in javascript

Posted: Wed Jun 13, 2018 7:09 am
by feededandrea
Sorry for not answer before, I'm new here and I didn't find the post.

Joan, as soon as I can, I will try to do that you said.

Heater, I didn't try exactly that, but I invert the Pins, and the other one start working but the other one no.

Re: Problem with PiGPIO in javascript

Posted: Fri Jun 22, 2018 12:26 pm
by Heater
I can't help noticing that you have a comma instead of a semicolon at the end of:

Code: Select all

var Gpio = require('pigpio').Gpio,
Although I can see that would make much difference.

Also you don't show us what value1 and value2 are set to before that code runs.