Go Down

Topic: Apprentice coder (Read 5 times) previous topic - next topic

Pedro147

AWOL yes that compiled ok for me too. With regard to the "I still have issues about the size of the arrays (or the loop lengths, whichever way you look at it)" I  added two more LED's (now eight) and changed the code to
Code: [Select]
int timer = 100;
int pins [8] = {
  3, 4, 5, 6, 7, 8, 9, 10 };
char led = B10000001;
int mask = 1;



void setup ()

{
for(int i = 3; i < 11; i++)
  pinMode(i, OUTPUT);
}


void loop ()

{

  for(int i=0; i<9; i++)
  {


    {
      if((mask & led) == 0)
        digitalWrite(pins[i], LOW);
      else digitalWrite(pins[i], HIGH);


      mask = mask << 1;


    }
  }
}

but still no luck. I suppose what I am asking is does the format of the code appear to be correct.The " mask = mask << 1;" at the end of the code doesn't quite look right to my very inexperienced eye  8)

Thanks for your help Pedro.

AWOL

#21
Oct 26, 2012, 04:22 pm Last Edit: Oct 26, 2012, 04:24 pm by AWOL Reason: 1
Code: [Select]
for(int i=0; i<9; i++)
Still unhappy.

How about the debug prints?

You might want to move "mask" and its initialsation into "loop ()"
"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.

Pedro147

I don't mean to sound unhappy, just frustrated  :smiley-mr-green: But suffice to say AWOL, that edit you just did suggesting
"You might want to move "mask" and its initialsation into "loop ()" did the trick. I tried the dedug print but something just flashed across the screen at light speed and  I couldn't remember enough about the serial monitor function to make it stay still until I could read it. So thanks very much  for your help and that gives me something to work with. Also thanks to PaulS for his suggestions and help. You fellas are so cluey  8)

PeterH


did the trick.


The latest code you posted is still running off the end of the array. It might run and look OK, but it's not right yet.
I only provide help via the forum - please do not contact me for private consultancy.

AWOL

Quote
I don't mean to sound unhappy, just frustrated

No, it is me that is still unhappy with the loop I quoted.
"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