setColor?

Working on a RGB LED
I no I need setColor
But what does it means?

But what does it means?

In what context?

Well what does it do?
Why do I need it
And when set a number for you to 255
Can I choose just any number I want to?

You're not making sense Mr. LM317. Setcolor is not a standard part of the Arduino C palate. It must come from a library or some other code you are looking at, and that you assume we have all seen. We haven't. I can guess at what setcolor does, but it would just be a guess.

So can you give us some background? Talk to us like we have no clue about what you are talking about. Show us where setcolor comes from and as much information about how you want to use it as you care to share. I suspect then you will get some useful answers.

Are you talking about this code?

/*
Adafruit Arduino - Lesson 3. RGB LED
*/
 
int redPin = 11;
int greenPin = 10;
int bluePin = 9;
 
//uncomment this line if using a Common Anode LED
//#define COMMON_ANODE
 
void setup()
{
  pinMode(redPin, OUTPUT);
  pinMode(greenPin, OUTPUT);
  pinMode(bluePin, OUTPUT);  
}
 
void loop()
{
  setColor(255, 0, 0);  // red
  delay(1000);
  setColor(0, 255, 0);  // green
  delay(1000);
  setColor(0, 0, 255);  // blue
  delay(1000);
  setColor(255, 255, 0);  // yellow
  delay(1000);  
  setColor(80, 0, 80);  // purple
  delay(1000);
  setColor(0, 255, 255);  // aqua
  delay(1000);
}
 
void setColor(int red, int green, int blue)
{
  #ifdef COMMON_ANODE
    red = 255 - red;
    green = 255 - green;
    blue = 255 - blue;
  #endif
  analogWrite(redPin, red);
  analogWrite(greenPin, green);
  analogWrite(bluePin, blue);  
}

Yes you don't want setColor function. You can just write :
analogWrite(redPin,255);//255 or value you like

but setColor function is used here because if you are using common anode led instead of common cathode you have to subtract your color value from 255. if you are using common cathode then you do not need setColor function. If you are using common anode please uncomment :
//#define COMMON_ANODE

1 Like

Yes!
Why that is the language C code I was using!!!

Mine has been tweaked by me a little but
Pretty much the same!!!

So if I put a number other than 255 on there will it make different color!??

If I choose any number in the binary
Up to 255
Will it make a different colour!??
Thanks
Mr.LM317

You will need to analogWrite the redPin, the bluePin and the greenPin to set an RGB color. You may not be able to perceive small differences, such as between 128,128,127 and 128,127,128, but 64,128,128 will be considerably different than 192,128,128.