Go Down

Topic: For loops?? (Read 3 times) previous topic - next topic

PaulS

And that big key at the bottom of the keyboard? You know which one. Use it more often. Ditto for that big one on the middle row of characters, on the right.

AWOL

#21
Sep 04, 2012, 11:42 am Last Edit: Sep 04, 2012, 12:19 pm by AWOL Reason: 1
And scope.
You need to pay more attention to scope.

Quote
code is real short i guess it should work, not

sp. "Code is real short I guess it should work. Not!"
"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.

Nick Gammon


Nick Gammon

Code: [Select]

void loop(){
x++
if(x%3==0)   {state1=!state1;digitalWrite(pin2,state2);}
if(x%13==0) {state2=!state2;digitalWrite(pin2,state2);}


That doesn't even compile, right?

Read this before posting a programming question

Antennas

I have tried that code Marco_C and I like it. I don't really get most of it yet... But in these lines here
ledTable  T[] =
//Pin  St Lopp  State 0          State 1            State 2          State 3         Wkup
{
  { 3, 0, 0, {{MB_HIGH, 25, 0}, {MB_LOW, 25, 0}, {MB_LOOP, 3, 0}, {MB_LOW, 300, 0}}, 0 },
  { 4, 0, 0, {{MB_HIGH, 25, 0}, {MB_LOW, 25, 0}, {MB_LOOP, 3, 0}, {MB_LOW, 300, 0}}, 0 },
  { 5, 0, 0, {{MB_LOW, 250, 0}, {MB_HIGH, 250, 0}, {MB_LOW, 250, 0}, {MB_LOOP, 4, 1}}, 0 },
  { 6, 0, 0, {{MB_LOW, 250, 0}, {MB_LOW, 250, 0}, {MB_HIGH, 250, 0}, {MB_LOOP, 4, 1}}, 0 },
  {7, 0, 0,  {{MB_LOW, 0, 0}, {MB_LOW, 500, 0}, {MB_HIGH, 500, 0}, {MB_LOOP, 4, 1}}, 0 },
};

I have fiddled with them somewhat. But I want the LED on pin 3 to do it's thing and it does..I have it flashing 3 times quickly and then wait, but I want it's mate on pin 4 to wait while it flashes then flash 3 times and then back to pin 3. They are a pair one flashes 3 times quickly then the other, on and off like that, but I can't get it work. They just flash together at the same time. How could I change it?

Also why is the loop in a different spot in two of the lines? (MB_LOOP)? I guess you can move it around to fit your LED state changes??

Thanks for the help ...

Andrew

Go Up