I am using an AC dimmer module to dim a 240V light. I would like to use node.js so I am using the pigpio module.
The script is not working as expected as the light bulb goes straight to 100% when I execute the node.js script.
The AC dimmer module is http://www.inmojo.com/store/krida-electronics/item/ac-led-light-dimmer-module-with-heatsink/
Module's Pins:
+5V -> device power, DC 5 volts
SYNC -> zero-cross detector output positive impulse (pulse length 200us)
GATE -> triac gate input pin
GND -> ground of low voltage side
I have connected Module's VCC, GND and Gate pins to raspberry's +5, GND pin 18 respectively.
(the wiring is actually done with a Raspberry Pi 3, ignore the Arduino board in the wiring diagram above)
My code:
var Gpio = require('pigpio').Gpio,
led = new Gpio(18, {mode: Gpio.OUTPUT}),
dutyCycle = 0;
led.pwmWrite(dutyCycle);
setInterval(function () {
led.pwmWrite(dutyCycle);
dutyCycle += 1;
if (dutyCycle > 255) {
dutyCycle = 0;
}
}, 20);
I have also tried with the led.hardwarePwmWrite() method, but I am a bit confused as to how this can be used.
Is there anything that can be fixed in my wiring, the above code or by implementing hardwarePwmWrite()?