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: 13407
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: 9325
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.

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

Re: Problem with PiGPIO in javascript

Fri Jun 22, 2018 12:26 pm

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.

Return to “Other programming languages”

Who is online

Users browsing this forum: PeterForth and 3 guests