Setting up debugger in platformIO for arduino sketches

Hello from a newbie …

A simple project but the process has got complicated, so please can you help me?
The application is triggered by light falling on an LDR input to the A0 pin.
Once triggered an output timer is started, interval1 ON duration, within which a nested second timer with ON interval3 and off interval4. Interval 2 is the OFF state. The output is D13 pin. I used millis() rather than delay() to overcome multitasking issues.
I wanted to step through the sketch to debug it and get it working correctly. I could not find an Arduino IDE version that would debug my UNO or NANO boards that I have. Version 2.xxx does not support these boards.
I turned my attention to VS Code with PlatformIO extension. The information also stated that Python must also be installed. I followed various online videos and have found myself more confused as the sketch and .ini adjustments have thrown more errors.
Once the final sketch is working do the additional debug libraries and platform.ini codes need to be retained, or should they be removed?
Is there a definitive article or book that correctly helps novices like me to progress and improve?

================================================
Sketch

*General Operation

one input
one output
two timer loops
  first timer loop = lights on time and lights off time but within that time loop a second timer loop = flicker on duration and flicker off duration

global parameters

*/

#include <Arduino.h>

#include "app_api.h"
#include "avr8-stub.h"

const int ldrPin = A0;  // set the INPUT  pin number
const int LEDpin = 13;  // set the OUTPUT pin number

const long interval_1 = 10000;  // it is dark so ENABLE the lights
const long interval_2 = 10000;  // it is still dark but DISABLE the lights

const long interval_3 = 1000;       // ON time for LED ARRAY
const long interval_4 = 2000;       // OFF time for LED ARRAY
int LEDState = LOW;                 // initial state of LED ARRAY
unsigned long ldrTimer = millis();  // set the start point for the timers
unsigned long ledTimer = millis();  // set the start point for the timers

// SET local parameters

void setup() {
  debug_init();
  Serial.begin(9600);       // set up serial monitor to display code messaging
  pinMode(LEDpin, OUTPUT);  // define LEDpin as output
  pinMode(ldrPin, INPUT);   // define the LDR pin as an input
  digitalWrite(LEDpin, LEDState);  // set initial LED state

  long ldrTimer = 0;  // set the start point for the timers

  long ledTimer = 0;  // set the start point for the timers
}

void loop() {
  //----------------------------------------------------------------------------------------
  // determine LDR State {
  int ldrState = analogRead(ldrPin);  // read the value  of the LDR pin
  unsigned long timeNow =
      millis();         // set time to the current time of the clock
  if (ldrState >= 300)  // compare LDR value to the required threshold
    Serial.println(
        "ldr_ON");  // if threshold is met print statement to the serial monitor
  //----------------------------------------------------------------------------------------
  // first loop ON
  // --------------------------------------------------------------------------------
  Serial.println("first loop ON");
  if ((timeNow - ldrTimer) >= interval_1)  // condition to END first loop time
    unsigned long ldrTimer = millis();     // start the ldr on period from now
  //-----------------------------------------------------------------------------------------------------

  // second loop ON
  {
    if (LEDState == HIGH)

      if ((timeNow - ledTimer) >= interval_3) Serial.println("second loop ON");
    {
      LEDState = LOW;                    // change the state of LED
      unsigned long timeNow = millis();  // remember Current millis() time
    }

    else {
      if ((timeNow - ledTimer >= interval_4))
      // Serial.println("second loop OFF");
      {
        LEDState = HIGH;                   // change the state of LED
        unsigned long timeNow = millis();  // remember Current millis() time
      }
    }
    {
      // Robojax LED blink with millis()
      digitalWrite(
          LEDpin,
          LEDState);  // turn the LED ON or OFF
                      //------------------------------------------------------------------------------------------
    }

    {
      if ((timeNow - ldrTimer >= interval_2))
        ;  // condition to EXIT first loop time
      Serial.println("first loop OFF");
    }
  }
}

and here is the platform.ini

; PlatformIO Project Configuration File

;

; Build options: build flags, source filter

; Upload options: custom upload port, speed and extra flags

; Library options: dependencies, extra library storages

; Advanced options: extra scripting

;

; Please visit documentation for the other options and examples

; Redirecting...

[env:nanoatmega328new]

platform = atmelavr

board = nanoatmega328new

framework = arduino

debug_tool = avr-stub

debug_port = com6

; GDB stub implementation

lib_deps = jdolinay/avr-debugger @ ~1.4

Thanks in advance