help needed for Zero-cross dimmer with Arduino and blynk

Hello everybody,
I really need your help here. After a couple of weeks spent reading articles and code, I managed to make the code running to dim a light bulb (both normal and LED ones). The code looks like below. My kind asks to you is now, to guide me how can I dim multiple bulbs, using the same Arduino Mega 2650 and, for each bulb, a PWM dimmer as presented above in this thread.
I have tried to include in the zero_cross_detect function the code for the second bulb but does not as desired. The behavior is the following:

sliding the second slider (V5) I can dim the second bulb
sliding the first slider (V4) then both bulbs get dimmed and, after a while, if I go with this slider to the minimum, Arduino freezes and both bulbs flicker really bad.
I have noticed that if the second slider is set such the bulbs are dimmed when sliding the first slider, then the bulbs goes crazy, flickering all around and the Arduino gets stuck.

I know it might not be a blynk per se issue but I really need your help here. Thank you very much in advance for guidance and patience.

In regards to hardware and connectivity, here are some bits:

I have an Arduino Mega 2650 that is connected to a power supply (12V) by a jack. The power supply provides 12Vcc and 5Vcc. From the 5Vcc side, I power the dimmers (
Each dimmer has on the output of a bulb, and the dimmer input is connected to 220V.
Zero-crossing pins from the dimmers are connected one to pin 18 and the other one to pin 19.
PWM pins are connected to pin 12 and 13 on Arduino board.
The sliders are defined in the app as connected to V4 respectively V5. They are set to retrieve a value from 85 to 5, I set them to send values all the time not only to release.

The code I wrote is presented below:

#define BLYNK_PRINT Serial // Comment this out to disable prints and save space
#include <SPI.h>
#include <Ethernet.h>
#include <BlynkSimpleEthernet.h>
#include <TimeLib.h>
#include <WidgetRTC.h>

#define W5100_CS 10
#define SDCARD_CS 4

#define triacApin1 12
#define triacApin2 13
int power1 = 3;
int power2 = 3;
int dimtime1;
int dimtime2;

char auth = “xxxxxxx”;

IPAddress server_ip (x, x, x, x);
byte arduino_mac = { 0xDE, 0xED, 0xBA, 0xFE, 0xFE, 0xED };
IPAddress arduino_ip (x, x, x, x);
IPAddress dns_ip (193, 231, 252, 1);
IPAddress gateway_ip (10, 130, 27, 255);
IPAddress subnet_mask(255, 255, 255, 0);

bool isFirstConnect = true;

void zero_cross_detect1(){
dimtime1 = (100 * power1);
delayMicroseconds(dimtime1); // Wait till firing the TRIAC
digitalWrite(triacApin1, HIGH); // Fire the TRIAC
delayMicroseconds(10); // triac On propogation delay (for 60Hz use 8.33)
digitalWrite(triacApin1, LOW); // No longer trigger the TRIAC (the next zero crossing will swith it off) TRIAC
void zero_cross_detect2(){
// Code for the second dimmer
dimtime2 = (100 * power2);
digitalWrite(triacApin2, HIGH);
digitalWrite(triacApin2, LOW);

power1 = param.asInt();

power2 = param.asInt();

// if (isFirstConnect){
// Blynk.virtualWrite(V4, 5);
// Blynk.virtualWrite(V5, 5);
// isFirstConnect = false;
// }

void setup() {
Blynk.begin(auth, server_ip, 8080, arduino_ip, dns_ip, gateway_ip, subnet_mask, arduino_mac);
while (Blynk.connect() == false){}
Serial.println(“Connected to Blynk”);
pinMode(triacApin1, OUTPUT);
pinMode(triacApin2, OUTPUT);
// digitalWrite(triacApin1, LOW);
// digitalWrite(triacApin2, LOW);
attachInterrupt(digitalPinToInterrupt(18), zero_cross_detect1, RISING);
attachInterrupt(digitalPinToInterrupt(19), zero_cross_detect2, RISING);

void loop() {;

Thank you in advance for the advices.

Break your code into two halves. One is the dimmer, the other the Blynk code.

Use the RobotDyn demo code and get both dimmers working without the Blynk code. Test the Blynk code by writing the output to the serial console. Only when both parts work independently, merge them back together.