I have been trying for days to figure out how to make an array that would help label my serial info. I have three sensors that are reading leds and printing values to my serial monitor. So far what I get on my serial monitor is=
A0=### A0=### A0=### A0=### A0=### A0=###
A1=### A1=### A1=### A1=### A1=### A1=###
A2=### A2=### A2=### A2=### A2=### A2=###
I know I need to make a character array of some sorts but I really do not know how to do it to get what I want. I want to take the (k = 0 ; k < 6 ; k++) in the code and add it to a character array so that it will cycle through them.
Something like= char Colors = (Yellow, White, Red, Uv, Blue, Green);
so that the outcome would be=
Yellow A0=### White A0=### Red A0=### Uv A0=### Blue A0=### Green A0=###
Yellow A1=### White A1=### Red A1=### Uv A1=### Blue A1=### Green A1=###
Yellow A2=### White A2=### Red A2=### Uv A2=### Blue A2=### Green A2=###
If there is someone who could please help me out there I would greatly appreciate it. The code below is where I need help. I have the areas marked with *** showing what I am trying to do. Just don't know how to do it or what to write to make it happen.
void loop()
{
for(j = 0 ; j < 6 ; j++)
{
***for(k = 0 ; k < 6 ; k++)
analogWrite(LED[j],255);
delay(100);
analogWrite(pcellgnd, LOW); //A0 Ground
analogWrite(ptrangnd, HIGH); //A1 Ground
analogWrite(uvptrangnd, HIGH); //A2 Ground
delay(3000);
***Serial.print(Colors[k]);
Serial.print("A0= ");
Serial.println(1024-analogRead(A0)); // PRINT VALUES
delay(100);
analogWrite(LED[j],0);
}
for(j = 0 ; j < 6 ; j++)
{
***for(k = 0 ; k < 6 ; k++)
analogWrite(LED[j],255);
delay(100);
analogWrite(pcellgnd, HIGH); //A0 Ground
analogWrite(ptrangnd, LOW); //A1 Ground
analogWrite(uvptrangnd, HIGH); //A2 Ground
delay(3000);
***Serial.print(Colors[k]);
Serial.print("A1= ");
Serial.println(1024-analogRead(A1)); // PRINT VALUES
delay(100);
analogWrite(LED[j],0);
}
for(j = 0 ; j < 6 ; j++)
{
***for(k = 0 ; k < 6 ; k++)
analogWrite(LED[j],255);
delay(100);
analogWrite(pcellgnd, HIGH); //A0 Ground
analogWrite(ptrangnd, HIGH); //A1 Ground
analogWrite(uvptrangnd, LOW); //A2 Ground
delay(3000);
***Serial.print(Colors[k]);
Serial.print("A2= ");
Serial.println(1024-analogRead(A2)); // PRINT VALUES
delay(100);
analogWrite(LED[j],0);
}
analogWrite(LED[j],0);
delay(100);
}
Thank you in advanced for all of those who read this post.