How to make 40KHz 50 % duty cycle?

please help me, i'm newbie. i I just use the Arduino for 2 months. thanks

Have tried googling for it?

One of the first hits: Google Code Archive - Long-term storage for Google Code Project Hosting.

Please be aware that you cannot use all pins for this and that it may influence the time keeping functionality of the Arduino libraries if you change the frequency on certain pins.

before i use ATmega8

TCCR1A=0xA2;
TCCR1B=0x19;
TCNT1H=0x00;
TCNT1L=0x00;
ICR1H=0x01;
ICR1L=0x8F;
OCR1AH=0x00;
OCR1AL=0x00;
OCR1BH=0x00;
OCR1BL=0x00;

can i use it for arduino?

void setup()
{
pinMode(13, OUTPUT);
}

void loop()
{
digitalWrite(13, HIGH);
delayMicroseconds(100); // Approximately 10% duty cycle @ 1KHz
digitalWrite(13, LOW);
delayMicroseconds(1000 - 100);
}

and i get it from http://arduino.cc/en/Tutorial/SecretsOfArduinoPWM but the value of 100 (delayMicroseconds(100):wink: just for duty cycle, and how about if i need 40KHz which part should i change?

Well, if 100 and 900 microseconds gives a 10% duty at 1kHz, what do you think you need to put in for about 40kHz?

If you can't be bothered to read the how to use this forum stick why should anyone be bothered to help you.

Hint - 40 KHZ is 25uS