Please help me for Arduino squarewave inverter 1.5khz with 10%duty cycle

Hello guys. I want to build inverter with frequency 1.5khz and duty cycle about 10% for my final project. Please help me to build program for my final project with pwm register in arduino uno. thanks :slight_smile: :slight_smile:

Hello i’am noob in this code. Can anyone help me with this code???. I want to change duty cycle to 10% with frequency 500hz. But my problem is how to change duty cycle in this code. Thank you very much and i very need your help guys
Here is my code:

//dynamic frequency generator
//for timer2
#include <avr/io.h>
#include <avr/interrupt.h>
unsigned long frequency = 1500;//0 ;//12khz = 12000… 1khz ok
void setup(){
pinMode(9,1);
pinMode(10,1);
DFG(frequency);
Serial.begin(57600);

}

void loop(){

}

void DFG(unsigned long tempfreq){
cli();//disable interupts
TCCR1A = 0;//registers for timer 1
TCCR1B = 0;
TCNT1=0;
TCCR1A |= _BV(COM1A0) + _BV(COM1B0);
TCCR1B |=_BV(WGM12);
TCCR1C = _BV(FOC1A);
if(tempfreq > 122 && tempfreq < 1000001){
OCR1A = (8000000/tempfreq)-1;//#TIMER COUNTS
TCCR1B |= _BV(CS10);
}
else if(tempfreq <= 122 && tempfreq > 15){
OCR1A = (1000000/tempfreq)-1;
TCCR1B |= _BV(CS11);
}
else if(tempfreq <= 15 && tempfreq > 4){
OCR1A = (125000/tempfreq)-1;
TCCR1B |= _BV(CS10) + _BV(CS11);
}

//TIMSK1 = _BV(OCIE1A);//TIMER1 COMPARE INTERUPT
sei();//enable interupts
}