Array Quastion

Hi all, I have a short question about passing arrays to functions.

...
int green[3]={255,0,0};
int blue[3]={0,255,0};
int red[3]={0,0,255};

void loop()  { 
 setColor(red);
 delay(100);
 setColor(blue);
}

void setColor(int color[3]) {
  analogWrite(greenPin,color[0]);
  analogWrite(bluePin,color[1]);
  analogWrite(redPin,color[2]);
}
...

This went wrong for the second setColor Call. I googeld and found that ist had somthing to do with array treated as pointers. Is there a easy way to pass the Data to the function?

Thanks alot.

Dennis

void setColor(int *color) {

Try changing just that.

Fragggy: This went wrong for the second setColor Call. I googeld and found that ist had somthing to do with array treated as pointers. Is there a easy way to pass the Data to the function?

It compiled OK for me. What was the error message?

GoForSmoke this does not change anything :-(

The Code compiles fine, but the LED only switches to red and than stais red.

I think the array is created in the first call and in the second call the data in color[] is still the same.

LOL, sorry, I missed step! Your led is turning blue but instantly turns red.

void loop()  { 
 setColor(red);
 delay(100);
 setColor(blue);
 delay(100);
}

GoForSmoke: LOL, sorry, I missed step! Your led is turning blue but instantly turns red.

tiny fix here

void loop()  { 
 setColor(red);
 delay(100);
 setColor(blue);
 delay(100);
}

BTW Nick, do you happen to know anyone at Dontronics?

GoForSmoke: BTW Nick, do you happen to know anyone at Dontronics?

No. I've bought stuff from them, but don't know them.