Pages: 1 [2]   Go Down
Author Topic: Small problem with laser-based persistance-of-vision system  (Read 1226 times)
0 Members and 1 Guest are viewing this topic.
Global Moderator
UK
Offline Offline
Brattain Member
*****
Karma: 238
Posts: 24306
I don't think you connected the grounds, Dave.
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

How helpful do you need it?
Logged

"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.

0
Offline Offline
Sr. Member
****
Karma: 0
Posts: 340
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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?
Logged

Dubuque, Iowa, USA
Offline Offline
Edison Member
*
Karma: 29
Posts: 2239
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

You'll want to look into the BitMath tutorial.

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

0
Offline Offline
Sr. Member
****
Karma: 0
Posts: 340
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Ok. I went from this code, which just produces a solid line:
Code:
void setup() {
  DDRD = DDRD | B11111100;
}

void loop()
{
  PORTD += B10000000;
}
to this code which produces a dash that is way too long.
Code:
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?
Logged

Global Moderator
UK
Offline Offline
Brattain Member
*****
Karma: 238
Posts: 24306
I don't think you connected the grounds, Dave.
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

"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.

Manchester (England England)
Offline Offline
Brattain Member
*****
Karma: 506
Posts: 31345
Solder is electric glue
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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

0
Offline Offline
Sr. Member
****
Karma: 0
Posts: 340
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

Global Moderator
UK
Offline Offline
Brattain Member
*****
Karma: 238
Posts: 24306
I don't think you connected the grounds, Dave.
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

"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.

0
Offline Offline
Sr. Member
****
Karma: 0
Posts: 340
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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
Logged

Manchester (England England)
Offline Offline
Brattain Member
*****
Karma: 506
Posts: 31345
Solder is electric glue
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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

0
Offline Offline
Sr. Member
****
Karma: 0
Posts: 340
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

0
Offline Offline
Sr. Member
****
Karma: 0
Posts: 340
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

This works:

Code:
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.
Logged

Pages: 1 [2]   Go Up
Jump to: