Tuesday 30 September 2014

microcontroller - Arduino 230v Light bulb dimming


Hey guys i have done a lot of research and testing on different circuits for 230v(50hz) or 220v light dimming, but i cant get my arduino to dim my light. This is the last thing i tried.


made this circuit : Circuit and Code Link


Code which i tried:


int AC_LOAD = 3;    // Output to Opto Triac pin
int dimming = 128; // Dimming level (0-128) 0 = ON, 128 = OFF


void setup()
{
pinMode(AC_LOAD, OUTPUT); // Set the AC Load as output
attachInterrupt(0, zero_crosss_int, RISING); // Choose the zero cross interrupt # from the table above
}

void zero_crosss_int() // function to be fired at the zero crossing to dim the light
{
// Firing angle calculation :: 50Hz-> 10ms (1/2 Cycle)
// (10000us - 10us) / 128 = 75 (Approx)

int dimtime = (75*dimming);
delayMicroseconds(dimtime); // Off cycle
digitalWrite(AC_LOAD, HIGH); // triac firing
delayMicroseconds(10); // triac On propogation delay
digitalWrite(AC_LOAD, LOW); // triac Off
}

void loop()
{
dimming = 128;

delay(100);
dimming = 75;
delay(100);
dimming = 25;
delay(100);

}


No comments:

Post a Comment

arduino - Can I use TI's cc2541 BLE as micro controller to perform operations/ processing instead of ATmega328P AU to save cost?

I am using arduino pro mini (which contains Atmega328p AU ) along with cc2541(HM-10) to process and transfer data over BLE to smartphone. I...