I need to pin output for 160 micro seconds.

I working on a metal detector. I need to digital out put for 160 microseconds. I want the frequency to be 100 khz . I can not find anything but microseconds. I want to use the arduino for the osc. and other functions. But I am not good a programing. If I could get an example of something that functions at that freq or close and time in microseconds. I might beable to figure the rest out.

Thanks in advance.

Marwynne
Texas

I would set one of the hardware timers to give interrupts at 100 KHz and in the ISR do:

digitalWrite(pin, HIGH);
delayMicroseconds(160-14);  // digitalWrite() takes about 14 microseconds.  Adjust to fit.
digitalWrite(pin,LOW);

Are you saying you want a burst of 100kHz lasting 160 us?

Pinout 167 microseconds pulse at 100 hz ? can the Arduino do this? I want to build a metal detector and require 167 micosecond pulse at 100 hz. I can pulse it for 1 milsecond but can't find where to pulse for a much shorter time period. Also how do you set up 100 hz repeat rate.

Any assistance would be appreciated . I can do this with hardware but want to try with software if possible.

Thanks

Marwynne

I refer you to this thread.
http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1175207378

Can do something like this:

// define varialbles, declare outputs used, etc.  Then:
void loop()
{
  // check if time needs updating

unsigned long currentMicros = micros();  // see how long its been

    if (currentMicros - previousMicros >= 10000) // 10mS, 100  Hz rate
    {
      // set up time for next update 
      previousMicros = previousMicros + 10000  ; 
     digitalWrite (pulseBit, HIGH);
delayMicroseconds(165);  // tweak a little if scope shows this is off
digitalWrite (pulseBit, LOW);
}  // end if 10mS
} // end loop

@OP:

Do NOT cross post.

It wastes time.

Moderator: Topics merged.