I want to generate PWM of frequency 40Khz with 60% duty cycle and there should be another signal of same frequency, but this other signal should be 180 degrees from the previous one.
please help, i have to complete my project.
/* sketch to output 40KHz signal, 60/40 waveform
25uS period, *.6 = 15uS, *.4 = 10uS
run on regular Arduino
*/
void setup(){
pinMode (2, OUTPUT);
pinMode (3, OUTPUT);
digitalWrite (2, LOW); // set initial states
digitalWrite (3, HIGH);
}
void loop(){
while (1){ // reduce jitter from main & loop code
delayMicroseconds(10);
PIND = PIND | 0b00001100; // toggle output by writng to input register
delayMicroseconds(15);
PIND = PIND | 0b00001100;
}
}
Thank You Sir, I will test the code.
Thanks for your help.
you can use a not gate to invert the output by 180 degrees