Go Down

Topic: Small problem with laser-based persistance-of-vision system (Read 2952 times)previous topic - next topic

AWOL

How helpful do you need it?
"Pete, it's a fool looks for logic in the chambers of the human heart." Ulysses Everett McGill.
Do not send technical questions via personal messaging - they will be ignored.

David82

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?

Chagrin

You'll want to look into the BitMath tutorial.

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

David82

Ok. I went from this code, which just produces a solid line:
Code: [Select]
`void setup() {  DDRD = DDRD | B11111100;}void loop(){  PORTD += B10000000;}`
to this code which produces a dash that is way too long.
Code: [Select]
`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?

AWOL

You could change the millisecond delay to something shorter.
Maybe a few tens of microseconds?
"Pete, it's a fool looks for logic in the chambers of the human heart." Ulysses Everett McGill.
Do not send technical questions via personal messaging - they will be ignored.

Grumpy_Mike

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

David82

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.

AWOL

There's a really useful reference section over at the main site.
"Pete, it's a fool looks for logic in the chambers of the human heart." Ulysses Everett McGill.
Do not send technical questions via personal messaging - they will be ignored.

David82

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

Grumpy_Mike

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

David82

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

David82

This works:

Code: [Select]
`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.

Go Up

Please enter a valid email to subscribe