Controling AC voltage 240v AC 50 Hz

It is possible to control 240v AC- 50Hz to control. I mean to say can i control the AC voltage using a ZERO VOLTAGE CROSSING detector for a smooth control on AC voltage.

I wouldn’t know why not.

Sorry if my question not clear. i mean to say i want control brightness of an AC lamp of 240v AC 50Hz

You may use the search feature of this forum for zero cross

https://community.particle.io/search?q=zero%20cross

1 Like

Thank you @ScruffR let me try this solution and i will let you know about my project progress.

hey @ScruffR is it necessary to use bridge rectifier in the circuit.

Depends on your circuit :wink:

Thank you @ScruffR i used arduino code directly with some modification please see.

// This #include statement was automatically added by the Particle IDE.
#include <SparkIntervalTimer.h>


volatile int i=0;               // Variable to use as a counter
volatile boolean zero_cross=0;  // Boolean to store a "switch" to tell us if we have crossed zero
int AC_LOAD = D5;                // Output to Opto Triac
int dimming = 0;                    // Dimming level (0-128)  0 = on, 128 = 0ff
int dim;                      // counting up or down, 1=up, -1=down

int freqStep = 75;    // This is the delay-per-brightness step in microseconds.
IntervalTimer myTimer;

void setup()
{
  pinMode(AC_LOAD, OUTPUT);// Set AC Load pin as output
  attachInterrupt(D2, zero_crosss_int, RISING);  // Choose the zero cross interrupt # from the table above
   Particle.function("setpos", setPosition);
   Particle.variable("getpos", &dim, INT);
}

void zero_crosss_int()  // function to be fired at the zero crossing to dim the light
{
  int dimtime = (75*dimming);    // For 60Hz =>65   
  delayMicroseconds(dimtime);    // Off cycle
  digitalWrite(AC_LOAD, HIGH);   // triac firing
  delayMicroseconds(10);         // triac On propagation delay (for 60Hz use 8.33)
  digitalWrite(AC_LOAD, LOW);    // triac Off
}                             

void loop()  {

}

int setPosition(String incValue) {
    dim = incValue.toInt();
   dimming = dim;
    return 0;
}

integrated with web page. Thank you @bko for the tutorial. my code is working fine but i want to ask is there any problem to the photon board. Does my photon board will get damaged with long use. This code is to control brightness of an AC bulb 240v 50Hz using your own web page.

Hey @Moors7 sorry i din’t get you. But now this code is working fine.

When working with mains power you have to know what you are doing otherwise you risk your or other peoples lives.
Only if you really do know about the dangers and understand and obey the local codes and regulations in respect to working with mains power we may feel comfortable with providing more advice.

3 Likes