I am seeing that the link @guix shared is for the Atmega IC timer, and the frequencies are very high. But I am using an esp32 and I saw this link: PWM example for LED that said one could use this code to accomplish the task
ledcSetup(0, 5000, 8); //(channel,frequency, bit resolution)
ledcAttachPin(2, 0); //(pin, channel)
ledcWrite(0, 127); //(channel, duty cycle [0-255]
@gerivega this is certainly an option and I think the first link that was posted refers to this as "bit banging a PWM". The disadvantage I see is that the duty cycle is not evenly distributed per unit time but is high at the beginning and low at the end of the time cycle. Seems like the quickest way to get the job done though.