analogWrite(laserPin, 10); for example makes a nice, short dash depending on the rpm of the motor.
the value can be 0-255. If "10" is used, it is on for 10 clicks and then off for 245 clicks. I need it to be on 5 clicks, and off 5 clicks, then repeat. Do you see what I mean?
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.
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?
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?
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