Status LED wont stay on with Delay

Hi Everyone,

New to Arduino here. Does anyone have any idea why this blink sequence would not be working correctly on my OPTA PLC? I am trying to leave the first LED on for 1 second, however when running it on the OPTA it does not stay on for 1 second. The program seems to be delayed for 1 second i.e the 2-4 status LEDS dont start for 1 second, however LED 1/D0 just blinks for around 100ms. then turns off.

/**
  Getting Started with Opta™
  Name: LED_Blink_Opta
  Purpose: Blink STATUS LEDs on Opta™.

  @author Arduino
*/

void setup() {
  pinMode(LED_D0, OUTPUT);
  pinMode(LED_D1, OUTPUT);
  pinMode(LED_D2, OUTPUT);
  pinMode(LED_D3, OUTPUT);
}

void loop() {
  digitalWrite(LED_D0, HIGH);
  delay(1000);
  digitalWrite(LED_D0, LOW);
  delay(100);
  
  digitalWrite(LED_D1, HIGH);
  delay(100);
  digitalWrite(LED_D1, LOW);
  delay(100);
  
  digitalWrite(LED_D2, HIGH);
  delay(100);
  digitalWrite(LED_D2, LOW);
  delay(100);
  
  digitalWrite(LED_D3, HIGH);
  delay(100);
  digitalWrite(LED_D3, LOW);
  delay(500);
}

what do you see if you do this?

void setup() {
  pinMode(LED_D0, OUTPUT);
}

void loop() {
  digitalWrite(LED_D0, HIGH);
  delay(5000);
  digitalWrite(LED_D0, LOW);
  delay(5000);
}

I switched to Arduino 2.2.1 IDE and it worked. Previously I was using Arduino PLC.

Hello!
I will add that the sketch does run inside the Arduino PLC IDE, te explanation of it is that the PLC IDE, combines the PLC IDE Runtime and the "embedded" Arduino Sketch on it, where it is meant to co-live but there are a few changes on how the resources are shared.

In this case the LEDs controlled from the Arduino Sketch will be less bright, and they will turn off on every PLC IDE task cycle, so the result at first might be seen as the LEDs are not lighting, which is false.

If you want to try out the PLC IDE, try to create a new project, open the default "main" ST program and write this code:

// Structured Text Blink sketch to be used with the Arduino PLC DE
cnt := cnt + 1;

IF cnt > 500 THEN
	sysLEDOutputs[1] := NOT(sysLEDOutputs[1]);
	cnt := 0;
END_IF;