Need a low frequency (can preset at each value of 15Hz to 25Hz) PWM signal

Result. Having had problems with the code, I progressively stripped it back to a simple LED flashing circuit peeling away code to find the problem. Took some time. In the end the code "pinMode(outPin,OUTPUT)" was needed in Void Setup. With this in place, all of the noise on the output signal disappeared.

So now have a 20Hz PWM signal (can preset at any other frequency) and can adjust the duty cycle in range 15% to 85% (again can preset the range required). Brilliant outcome... now just need to try it with the treadmill controller board and find the exact frequency needed to trigger motion.

Thank you to all contributors, most of all wvmarle who stuck with me through the strange problems. A1.

Final code is below with explanation of Purpose, Design, Testing and Working Status upfront.

// Purpose: Produce PWM signal at 20Hz frequency and duty cycle of min'm of 15 % and max'm of 85%, the pot
// rotated for any value in between. For use to control LED brightness or as input signal to motor controller

// Design: Arduino UNO with 1K ohm input pot. Resistance value, pot wiper into pin A0
// pot has VCC from 5v pin and Ov from Grd pin). Output PWM signal is on pin 13.
// V4 has the line of code pinMode(outPin,OUTPUT); that removed the noisy Lo output signal in earlier versions.

// To preset the frequency, set the cycle time in the code , set variable 'period' (in uS) (1 / frequency)

// Testing: Oscillosocpe on output pin 13, unloaded, then with external LED. Yet to test on motor controller

// Working status OPERATIONAL. PRODUCES PWM 20 Hz OUTPUT SIGNAL, VARYING POT CHANGES THE DUTY CYLE #15% TO 85%

const byte potPin = A0; // Analog input pin that has the potentiometer wiper resistance value
const byte outPin = 13; // PWM output pin that Motor Controller) (or LED in testing) is attached to

float dutyCycle; // Defines the duty cycle, the % of the period (the cycle time) the PWM pulse is high
unsigned long period; // Defines the cycle time ( 1 / frequency) for PWM output
unsigned long lastChange; // The variable for incrementing the time through the loop
int outState = 0;; // The variable holding value of Hi or Lo output that is derived through the loop

void setup() {
pinMode(outPin,OUTPUT); //ADD THIS CODE LINE TO STOP THE NOISE PROBLEM
period = 33000; // 50,000 us period, to be used to set the output signal at 20Hz frequency.
}

void loop() {

dutyCycle = map(analogRead(potPin), 0, 1023, 8500, 1500) / 10000.0; // returns 15% to 85% duty cycle range based on pot rotation reading 0-1023.
unsigned long onTime = period * dutyCycle; // defines the high duration in us.
unsigned long offTime = period * (1 - dutyCycle); // defines the low duration in us.

if (outState == HIGH) {
if (micros() - lastChange > onTime) {
outState = LOW;
lastChange += onTime;
}
}
else {
if (micros() - lastChange > offTime) {
outState = HIGH;
lastChange += offTime;
}
}
digitalWrite(outPin, outState);
}

Andrew_S_C:
I know the controller board needs a 5v (@ Hi) input signal frequency of somewhere between 15 and 25Hz (I need to preset to each frequency value and, by trial and error, find the exact frequency that triggers the motor movement. The duty cycle will be in the range of 15% to 85% for the motor speed range.

A loop command may work but I've been concerned that just using the delay function would mess up the duty cycle percentage which is crucial to motor speed setting.

25Hz is 40 millis. If 40 divisions is a bit inaccurate, then use micros.

I suffix variables with the unit of measurement, so microseconds is us.

double frequency_Hz = 20.0; // adjust this to what your board needs
uint32_t wavelength_us = 1000000.0 /  frequency_Hz;

double dutycycle_pct = 35;
uint32_t ontime_us = (double) wavelength_us * dutycycle_pct / 100.0; 

uint32_t cycleStart_us;

void setup() {
   cycleStart_us = micros();
   pinMode(pin, OUTPUT);
   digitalWrite(pin, HIGH);
}

void loop() {
  uint32_t us = micros() - cycleStart_us;
  while(us >=  wavelength_us) {
    // this method of adjusting the cyclestart gives more accurate cycles
    cycleStart_us += wavelength_us;
    us -= wavelength_us;  
  }

  digitalWrite(pin, us < ontime_us ? HIGH : LOW);
}