Hey, guys!
I'm a total noob, so please be gentle. I am having a problem that is totally dumbfounding me. I am using an Arduino Uno. I have a function written that cycles through various RGB values to send to a RGB LED. In this particular case, the trigger passes no value resulting in 'eyeColor' being incremented by 1 every time it is called. The problem is that it the entire program locks up when it hits case 8 where it uses the values in the assigned array. The serial printout shows me what I am supposed to see...but that's it. Any ideas? This may be painfully simple but I am beyond stumped. Please help. Thanks.
int ledRed=9;
int ledGreen=10;
int ledBlue=11;
int eyeColor;
int eyeColorMax=9;
int eyeRGB[3]={100,150,200};
void setup(){
pinMode(ledRed,OUTPUT);
pinMode(ledGreen,OUTPUT);
pinMode(ledBlue,OUTPUT);
}
void loop(){
/* contains code that calls 'functionEyeColor(0)' function */
}
void functionEyeColor(int value){
if (value){
eyeColor=value;
} else {
eyeColor++;
}
if (eyeColor>=eyeColorMax)
eyeColor=0;
switch(eyeColor){
case 0:
tempRed=0;
tempGreen=0;
tempBlue=0;
break;
case 1:
tempRed=255;
tempGreen=0;
tempBlue=0;
break;
case 2:
tempRed=0;
tempGreen=255;
tempBlue=0;
break;
case 3:
tempRed=0;
tempGreen=0;
tempBlue=255;
break;
case 4:
tempRed=255;
tempGreen=255;
tempBlue=0;
break;
case 5:
tempRed=255;
tempGreen=0;
tempBlue=255;
break;
case 6:
tempRed=0;
tempGreen=255;
tempBlue=255;
break;
case 7:
tempRed=255;
tempGreen=255;
tempBlue=255;
break;
case 8: /* I have also tried hard coding the values below with the same result. */
tempRed=eyeRGB[0];
tempGreen=eyeRGB[1];
tempBlue=eyeRGB[2];
break;
}
analogWrite(ledRed,tempRed);
analogWrite(ledGreen,tempGreen);
analogWrite(ledBlue,tempBlue);
Serial.print(F("\r\neyeColor: "));
Serial.print(eyeColor);
Serial.print(F("\ttempRed: "));
Serial.print(tempRed);
Serial.print(F("\ttempGreen: "));
Serial.print(tempGreen);
Serial.print(F("\ttempBlue: "));
Serial.print(tempBlue);
}