Help run this arduino code with blynk

Details-
• Arduino Mega 2560 with USB
• Android Oero
• Blynk server

The below I have posted a code. Basically, there are four traffic poles with three lights- Red, orange and greeN on each pole. I want to put a one second time interval to change from one light to the other. And, when I click on a button off all lights should get turned off. This is working on my Arduino when I was using RF module. But I have no idea how to do this with blynk. Please help me how to start or atleast suggest what changes needs to be done in my below arduino code


void loop()
{
///////// FIRST POLE///////////
digitalWrite(L1R, LOW);digitalWrite(L1G, HIGH);digitalWrite(L2R, HIGH);digitalWrite(L3R, HIGH);digitalWrite(L4R, HIGH);delay(1000);
digitalWrite(L1G, LOW);digitalWrite(L1O, HIGH);delay(500);digitalWrite(L1O, LOW);digitalWrite(L1R, HIGH);
///////////// SECOND POLE////////////
digitalWrite(L2R, LOW);digitalWrite(L2G, HIGH);digitalWrite(L1R, HIGH);digitalWrite(L3R, HIGH);digitalWrite(L4R, HIGH);delay(1000);
digitalWrite(L2G, LOW);digitalWrite(L2O, HIGH);delay(500);digitalWrite(L2O, LOW);digitalWrite(L2R, HIGH);
//////////////THIRD POLE////////////////
digitalWrite(L3R, LOW);digitalWrite(L3G, HIGH);digitalWrite(L2R, HIGH);digitalWrite(L1R, HIGH);digitalWrite(L4R, HIGH);delay(1000);
digitalWrite(L3G, LOW);digitalWrite(L3O, HIGH);delay(500);digitalWrite(L3O, LOW);digitalWrite(L3R, HIGH);
//////////////FOURTH POLE////////////
digitalWrite(L4R, LOW);digitalWrite(L4G, HIGH);digitalWrite(L2R, HIGH);digitalWrite(L3R, HIGH);digitalWrite(L1R, HIGH);delay(1000);
digitalWrite(L4G, LOW);digitalWrite(L4O, HIGH);delay(500);digitalWrite(L4O, LOW);digitalWrite(L4R, HIGH);
}

@rameshpersuader please edit your post, using the pencil icon at the bottom, and add triple backticks at the beginning and end of your code so that it displays correctly.
Triple backticks look like this:
```
Copy and paste them if you can’t find the correct characters on your keyboard.

Pete.

You can remove all this from your loop. Search “clean void loop” also in the docs about Blynk best practices. This will explain how to call functions on timer.setInteral. The Simple Timer is imbedded in the Blynk lib so you can use 16 timers under one timer declaration.

1 Like

Or another way would be to use the ticker library.

Both will be valuable experience down the road.