Small problem with laser-based persistance-of-vision system

analogWrite(laserPin, 10); for example makes a nice, short dash depending on the rpm of the motor.

You know the PWM frequency and the duty cycle, so the pulse length should be a simple calculation.

It is a matter of synchronising the PWM output to the motor rotation.
There are many ways of doing this.
One is with a sensor for each rotation, an other is using a phase locked loop to synchronise the motor speed to the PWM frequency.

You can change the PWM frequency to be much faster than the default.

You guys are misunderstanding the current problem a little. I'm not worried about alignment yet. Let me rephrase it this way; I need to figure out what code would give me the absolute shortest, most frequent pulses on an output pin. Imagine a square wave on an oscilloscope. I need to compress that wave as far as the arduino can handle. I need it to blink/pulse as fast as it possibly can.

I need to figure out what code would give me the absolute shortest, most frequent pulses on an output pin.

Direct port manipulation should get you up to a few mega Hertz.
Occasional glitch for timer overflow interrupts, though.

That's cool.. I have no idea what the code is for that though.

Some good search terms though

I found this Arduino Reference - Arduino Reference but the example isn't as helpful as I need it to be.

How helpful do you need it?

So I guess this: DDRD = DDRD | B11111100; would go in setup.. and in the loop, if I want to change pin 7 on and off, I would alternate between PORTD = B10000000; and this: PORTD = B00000000; Is there a way to do that last part with one line of code in the loop instead of using if statements?

You'll want to look into the BitMath tutorial.

To do specifically what you're asking you could just PORTD += B10000000.

Ok. I went from this code, which just produces a solid line:

void setup() {
  DDRD = DDRD | B11111100;
}

void loop()
{
  PORTD += B10000000;
}

to this code which produces a dash that is way too long.

void setup() {
  DDRD = DDRD | B11111100;
}

void loop()
{
  delay(1);
  PORTD += B10000000;
}

How would I delay shorter than that so that I find a middle ground which produces dots right next to each other as opposed to a solid line or long dashes?

You could change the millisecond delay to something shorter.
Maybe a few tens of microseconds?

Also what part of make the PWM frequency higher do you not understand?

AWOL:
You could change the millisecond delay to something shorter.
Maybe a few tens of microseconds?

That would be great. How do you do that? I've only ever heard of the delay() function.

There's a really useful reference section over at the main site.

Grumpy_Mike:
Also what part of make the PWM frequency higher do you not understand?

The problem with PWM is, as I explained earlier, if you use analogOut(laserPin, 10); for example, its on for 10 clicks but off for 245 clicks! That's a big problem

No you do not understand.
You use a PWM value of 128 BUT you change the PWM FREQUENCY!!!

Grumpy_Mike:
No you do not understand.
You use a PWM value of 128 BUT you change the PWM FREQUENCY!!!

ooooooohh..

This works:

void loop()
{
  delayMicroseconds(100);
  PORTD += B10000000;
}

If the value is too small it becomes a solid line. Probably because the wave isn't very square. Fixing that though is over my head.