pwm

hello guys. i dont know the arduino programming, but i want to make a program for PWM with user define duty cycle. user should able to change duty cycle from serial monitor. for that we need to change delay between making perticular pin high or low. so user should able to enter that delay in terms of duty cycle percentage. can anybody give me this code. if yes i will post the all logic and calculation. please let me know i need this for project work. its urgent. i request u for help

I think there is an example for receiving serial data in the IDE.
You can get the TimerOne library from the internet.
See:
https://playground.arduino.cc/Code/Timer1

const byte OutputPin = 3;  // Output on one of the PWM pins
int Percent;
void setup() {
    Serial.begin(19200);
}

void loop() {
    if (Serial.available())
        Percent = Serial.parseInt();
    if (Percent >= 0 && Percent <= 100)
        analogWrite(OutputPin, map(Percent, 0, 100, 0, 255));
}
void loop() {
    if (Serial.available)

oops

AWOL:

void loop() {

if (Serial.available)



oops

Oops, indeed. Fixed it above.