I’m new with electronic and Arduino. Before that i’ve problem and i will try to solve by myself. Now I’ve some problem and hope some body can advise to me.
My stuff
- Arduino Yun
- 8 CHANNEL DIGITAL LIGHT DIMMER with zero-cross detector Brand : KRIDA Electronics
- LED light 1000w
- Cannot use timerone.h
I would like to dim my LED light. Now my code can dim with Blynk but just only few minutes. I think i send data a lot to server and its kick from server Blynk. I don’t know why, coz’ i set interval time already. So please advise some hint to me. Thank you
#define BLYNK_PRINT Serial
#include <SPI.h>
#include <Bridge.h>
#include <BlynkSimpleYun.h>
#include <SimpleTimer.h>
#define triacApin 6
int power = 0;
char auth[] = "";
SimpleTimer timer;
void setup()
{
Serial.begin(115200);
delay(10);
Blynk.begin(auth);
delay(10);
pinMode(triacApin, OUTPUT);
digitalWrite(triacApin, LOW);
timer.setInterval(1000L, zero_cross_detect);
attachInterrupt(0, zero_cross_detect, FALLING);
}
BLYNK_WRITE(V1)
{
Serial.print("Power: ");
Serial.println(param.asStr());
power = param.asInt();
}
void zero_cross_detect()
{
if(power > 0){
int dimtime = (75*power);
delayMicroseconds(dimtime); // Wait till firing the TRIAC
digitalWrite(triacApin, HIGH); // Fire the TRIAC
delayMicroseconds(10); // triac On propogation delay (for 60Hz use 8.33)
digitalWrite(triacApin, LOW); // No longer trigger the TRIAC (the next zero crossing will swith it off) TRIAC
}
else
{
digitalWrite(triacApin, LOW);
}
}
void loop()
{
Blynk.run();
timer.run();
}