Problem with conversion from const boolean to boolean

Hello everyone I'm just starting with arduino and I have to my project. I would like to have 4 RGB leds switch colors simultaneously and then compare if one of the RGB's has the same color as another I get a point. For the moment I have this code but I keep getting these invalid conversion errors when I try to add more RGB's at the bottom of my code.

//RGB LED pins
int ledDigitalOne[] = {11, 10, 9};
int ledDigitalTwo[]={6,5,3};
int ledDigitalThree[]={A0,A1,A2};
int ledDigitalFour[]={A3,A4,A5};

const boolean ON = 255;
const boolean OFF = 0;

//voorafbepaalde kleuren
const boolean RED[] = {ON, OFF, OFF};
const boolean GREEN[] = {OFF, ON, OFF};
const boolean YELLOW[] = {ON, ON, OFF};
const boolean CYAN[] = {OFF, ON, ON};
const boolean MAGENTA[] = {ON, OFF, ON};

// vooraf bepaalde kleuren in array steken
const boolean* COLORS[] = {RED, GREEN, YELLOW, CYAN, MAGENTA};

//hiermee worden de huidige kleuren opgeslaan om dan te vergelijken
int colorRGB1;
int colorRGB2;
int colorRGB3;
int colorRGB4;

//punten van het spel
int punten;

void setup(){
Serial.begin(9600);}

void loop(){
randomColor();

//hier controleren of kleuren dezelfde zijn
if (colorRGB1==colorRGB2){
punten+=1;}
if (colorRGB1==colorRGB3){
punten+=1;
}
if (colorRGB1==colorRGB4){
punten+=1;
}
if (colorRGB2==colorRGB3){
punten+=1;
}
if (colorRGB2==colorRGB4){
punten+=1;
}
if (colorRGB3==colorRGB4){
punten+=1;}}

void setColor(int* led, boolean* color){
for(int i = 0; i < 3; i++){
analogWrite(led_, color*);}}_
void randomColor(){
_
int rand = random(0,sizeof(COLORS) / 2); //random nummer van kleuren in array*_
* colorRGB1=rand;*
* setColor(ledDigitalOne, COLORS[rand]); *
* delay(1000);}*

Your code compiles without errors...

can you explain what goes wrong exactly?

Look at the code in the post. Near the end, there is a line:

analogWrite(led*, color);}}*

Why does it turn into italics halfway through this line? Please the post at the top of the list of threads named "How to use this forum".

You write

const boolean ON = 255;
const boolean OFF = 0;

surely a boolean can have values only of 0 or 1....

regards

Allan

Like Chris said... something happened in your post in this section of your code:

void setColor(int* led, boolean* color){
 for(int i = 0; i < 3; i++){
 analogWrite(led, color);}}

I'm sure you have an array being indexed by i that got interpreted as a forum italics command. If you post your code in the code blocks, it will display correctly for us to see.

Hint: use the </>

And for us to really help, (as Kevin said), you'll need to tell us what type of error you get. Can you post it?

Also - you're writing Boolean values to your LED with an analogWrite. Do you mean to use integers and digitalWrite?

allanhurst:
surely a boolean can have values only of 0 or 1....

false or true.

Hi,
Welcome to the forum.

Please read the first post in any forum entitled how to use this forum.
http://forum.arduino.cc/index.php/topic,148850.0.html then look down to item #7 about how to post your code.
It will be formatted in a scrolling window that makes it easier to read.

Thanks.. Tom... :slight_smile:

I believe the OP is scared off.