I use as board this one.
and for 230volt output this.
http://www.inmojo.com/store/krida-electronics/item/4-channel-ac-light-dimmer-arduino--v2/#shipping
The i use is the code you send to my.
#include <TimeLib.h>
#include <TimeAlarms.h>
//AlarmId id;
int AC_LOAD1 = 10; // Output to Opto Triac pin
int AC_LOAD2 = 11; // Output to Opto Triac pin
volatile int dimming1 = 128; // Dimming level (0-128) 0 = ON, 128 = OFF
volatile int dimming2 = 128; // Dimming level (0-128) 0 = ON, 128 = OFF
void setup() {
// Initialize Serial and wait for port to open:
// Bridge.begin();
Serial.begin(115200);
setTime(8, 29, 30, 1, 1, 11); // set time to Saturday 8:29:30am Jan 1 2011
// create the alarms, to trigger at specific times
Alarm.alarmRepeat(8, 30, 0, LightOn); // 8:30am every day
Alarm.alarmRepeat(8, 33, 30, LightOff); // 8:30;30am every day
pinMode(AC_LOAD1, OUTPUT); // Set the AC Load as output
pinMode(AC_LOAD2, OUTPUT); // Set the AC Load as output
attachInterrupt(0, zero_crosss_int, RISING); // Choose the zero cross interrupt # from the table above
}
void loop() {
Serial.print("min/sec ");
digitalClockDisplay();
Serial.println("dimming values");
Serial.print(dimming1);
Serial.print(":");
Serial.println(dimming2);
Alarm.delay(1000); // wait one second between clock display
}
// functions to be called when an alarm triggers:
void LightOn() {
dimming1 = 10; //Full = 0
dimming2 = 1; //Full = 0
}
void LightOff() {
dimming1 = 128; //Off = 128
dimming2 = 120; //Off = 128
}
void digitalClockDisplay() {
// digital clock display of the time
//Serial.print(hour());
printDigits(minute());
Serial.print(":");
printDigits(second());
Serial.println();
}
void printDigits(int digits) {
//Serial.print(":");
if (digits < 10)
Serial.print('0');
Serial.print(digits);
}
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 dimtime1 = (75 * dimming1);
int dimtime2 = (75 * dimming2);
if ( dimtime1 > dimtime2)
{ delayMicroseconds(dimtime2);
digitalWrite(AC_LOAD2, HIGH);
delayMicroseconds(10);
digitalWrite(AC_LOAD2, LOW);
delayMicroseconds( dimtime1 - dimtime2);
digitalWrite(AC_LOAD1, HIGH);
delayMicroseconds(10);
digitalWrite(AC_LOAD1, LOW);
}
else
{ delayMicroseconds(dimtime1);
digitalWrite(AC_LOAD1, HIGH);
delayMicroseconds(10);
digitalWrite(AC_LOAD1, LOW);
delayMicroseconds( dimtime2 - dimtime1);
digitalWrite(AC_LOAD2, HIGH);
delayMicroseconds(10);
digitalWrite(AC_LOAD2, LOW);
}
}
A little bit misunderstanding, i changed the value "LightOff" from 0 to 50.
To find out how the board works with the value"50" this to see what happens with the time .
Regards Henk,
