This is a library for performing AC power control with Pulse Code Modulation (PWM) and zero cross detection. With the use of power electronics (TRIACs, SSRs, e.t.c.) you can control the power of an AC load, like lights (dimming), audio, fans, motors, heating elements, ovens, kettles e.t.c. The library was designed with the maximum of simplicity and minimality in order to barely affect the size of your sketch.
Reviewed: 2013 - Dimitris El. Vassis
Download: ACPWM Library
Installation - Use
Unzip ACPWM.zip and place the extracted folder inside the libraries folder of your Arduino setup. At the start of your code, use the following statement to include the library in your sketch: #include <ACPWM.h> Use the methods provided with the following statement: ACpwm.method(); where method() is the name of the method you want to use.
void initialize(int frequency, int zeroControlPin, int zeroPulseMode, int pwmPin, int scale);
Initializes the power control operation by setting the mains frequency, the pin of the zero cross detection pulse, the mode of the pulse (LOW, CHANGE, RISING, FALLING), the pin that makes the pwm control, and the scaling of the set point.
void setLatch(int onLatch, int offLatch);
Sets the latching due to response of electronic devices, in the HIGH and LOW state of the zero control pulse respectively.
void setDutyCycle(int dutyCycle);
Sets the duty cycle (ON period) of the PWM operation.
The following program uses a potentiometer, a zero crossing detector and a switching unit (e.g. TRIAC) to dim a light with the use of Arduino.