Go Down

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

#### AWOL

#15
##### May 19, 2012, 10:17 pm
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

#16
##### May 19, 2012, 10:24 pm
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

#17
##### May 19, 2012, 10:41 pm
You'll want to look into the BitMath tutorial.

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

#### David82

#18
##### May 19, 2012, 10:51 pm
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

#19
##### May 19, 2012, 10:53 pm
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

#20
##### May 19, 2012, 10:54 pm
Also what part of make the PWM frequency higher do you not understand?

#### David82

#21
##### May 19, 2012, 10:55 pm

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

#22
##### May 19, 2012, 10:57 pm
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

#23
##### May 19, 2012, 11:05 pm

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

#24
##### May 19, 2012, 11:08 pm
No you do not understand.
You use a PWM value of 128 BUT you change the PWM FREQUENCY!!!

#### David82

#25
##### May 19, 2012, 11:08 pm

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

#### David82

#26
##### May 19, 2012, 11:10 pm
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