feededandrea
Posts: 2
Joined: Sun Jun 10, 2018 5:56 am

Problem with PiGPIO in javascript

Sun Jun 10, 2018 6:11 am

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!

User avatar
joan
Posts: 13358
Joined: Thu Jul 05, 2012 5:09 pm
Location: UK

Re: Problem with PiGPIO in javascript

Mon Jun 11, 2018 10:12 am

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.

Heater
Posts: 9231
Joined: Tue Jul 17, 2012 3:02 pm

Re: Problem with PiGPIO in javascript

Mon Jun 11, 2018 10:14 am

Have you tried removing the led1 code and just driving led2 on it own?

feededandrea
Posts: 2
Joined: Sun Jun 10, 2018 5:56 am

Re: Problem with PiGPIO in javascript

Wed Jun 13, 2018 7:09 am

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.

Return to “Other programming languages”

Who is online

Users browsing this forum: No registered users and 1 guest