Does this code work as a PWM?
dutyCycle = analogRead (0) / 1023;    // dutyCycle potentiometer is at analong pin 0


Dividing a small integer by a bigger integer leaves you with 0. If analogRead() returns 1023 you will get a result of 1. Everything else will give you 0. You need to divide by a floating point number - either 1023.0 or 1023f.

analogRead() is slow. Because it is happening between every single cycle of your square wave you can expect to never get to anywhere near 100% duty cycle. There will always be a LOW period where the analog input is being read.

You should:


Fix your integer division problem
Make the ADC "free running" or interrupt driven so it doesn't interfere with your PWM generation


... Or ...


Fix your integer division problem
Make your PWM generation timer driven, either using the OC peripheral or manually with interrupts, so it doesn't interfere with the analog reading.


... Or ...

You could even do both. Make everything as asynchronous as possible leaving your loop() free to just do the heavy work of calculating the values.