sarfata / pi-blaster.js

NodeJS module to control pi-blaster
MIT License
107 stars 27 forks source link

Question - What is the pin number #4

Closed spuder closed 9 years ago

spuder commented 9 years ago

The example shows setting first pin to 40%

piblaster.setPwm(0, 0.4);

What does 0 map to? Is it the GPIO/Broadcom mapping because there isn't a pin 0.

http://pi.gadgetoid.com/pinout

spuder commented 9 years ago

Still not sure what 0 maps to, but I found the following table https://github.com/sarfata/pi-blaster/blob/master/pi-blaster.c#L39-51

static uint8_t known_pins[] = {
        4,      // P1-7
        17,     // P1-11
        18,     // P1-12
        27,     // P1-13
        21,     // P1-13
        22,     // P1-15
        23,     // P1-16
        24,     // P1-18
        25,     // P1-22
};
molda commented 9 years ago

Hi i think the number 0 in piblaster.setPwm(0, 0.4) actualy refers to first pin in known_pins, which is pin 4 (P1-7)

I used pi-blaster.js with PiBits/ServoBlaster which allows for passing array of pins you want to use.

With pi-blaster you are stuck with known_pins.

Since pi-blaster is a fork of ServoBlaster you should have no problem to use it instead and use pins you want.

Hope it helps.

spuder commented 9 years ago

Thanks,

This is how I eventually got it working

piblaster.setPwm(17, red/255 );
piblaster.setPwm(22, green/255 );
piblaster.setPwm(23, blue/255 );

https://github.com/spuder/rpi-redditbutton/blob/master/button.js#L10-12