Go Down

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

AWOL

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

Go Up