How can I improve my code for a 100kHz pulse

Would this be the best path to take? This code is doing what I want I attempting according to oscilloscope. I am using atmega328P part of a breadboard buddy. According to the oscilloscope it flickers frequently by .01 and then the whole 100k flickers to what looks like 60k for like a microsecond. Application: using to send output to a proximity sensor

is there room for improvement?

#include <util/delay.h>
void setup()
  pinMode(PD3, OUTPUT);

void loop()
  digitalWrite(PD3, HIGH);
  digitalWrite(PD3, LOW);

Best to use non-blocking timing using millis() or micros().

Non-blocking timing tutorials:
Several things at a time.
Beginner’s guide to millis().
Blink without delay().

Did you read the documentation for the functions that you are using? In the reference for <util/delay.h> found here Is a note that has special instructions. Did you follow those instructions?


In order for these functions to work as intended, [b]compiler optimizations must be enabled[/b], and the delay time must be an expression that is a known constant at compile-time. If these requirements are not met, the resulting delay will be much longer (and basically unpredictable), and applications that otherwise do not use floating-point calculations will experience severe code bloat by the floating-point library routines linked into the application.

Emphasis added.

I'd use one of the chip's hardware timers. It will give you the most accurate and jitter-free timing possible. Also, it will require no processor involvement once the timer is set up.