Hello.
I need help with my circuit. I created circuit like below.
I also upload some code to arduino.
const int ZERO_CROSSING = 2;
const int OUT = 5;
const int POT = A5;
volatile int zeroCrossCount = 0;
int power = 0;
void setup() {
pinMode(OUT, OUTPUT);
pinMode(ZERO_CROSSING, INPUT_PULLUP);
pinMode(POT, INPUT);
attachInterrupt(digitalPinToInterrupt(ZERO_CROSSING), zeroCross, FALLING);
}
void loop() {
power = map(analogRead(POT), 0, 1023, 0, 100);
digitalWrite(OUT, zeroCrossCount < power || power == 100);
}
void zeroCross() {
zeroCrossCount = (zeroCrossCount + 1) % 101;
}
Unfortunately, despite connecting the system as shown in the drawing, a problem occurred. The bulb that I used as a load (R_LOAD in the picture) blinks after starting the system. The flashing follows a sine wave. Depending on the setting of the "power" variable, the bulb lights up for a shorter or longer time and is turned off for a shorter or longer time - according to the period of the sine wave. Ultimately, my system would work with a 3kW boiler heater or a 2.5kW radiator, so I'm a bit afraid of this flashing. Is it possible to modify the code or connections on the system to make the bulb glow continuously? What could be causing the flashing?
Previously, I created a circuit based on a ready-made SSR component. However, I used analog inputs from Arduino to control it, so I controlled the analogWrite function in the code instead of digitalWrite. It was then possible to set the power in the parameters of this function in the form of an appropriate number. This code allowed me to smoothly control the bulb, which was lit all the time with the power I entered in the Arduino code. The bulb wasn't blinking. Unfortunately, when I connected a larger load to such a system, the voltage measured in the socket every second fluctuated, for example, from 255V to 242V (the device had, for example, 3kW of power). And then again from 242V to 255V in a second. I decided not to use analogWrite because I found that this command was responsible for such fluctuations.
The bulb bliks exactly like that. Blinking periods are different and depends on variable power.