error:" 'setColor' was not declared in this scope"

Hi everyone,
I'm trying to write a code for the Arduino Uno which sets a RGB LED to a specific colour according to the temperature.

OK so far (there's a lot of stuff online)....but unfortunately I can't find any information about the error message " 'setColor' was not declared in this scope".
Does anyone have an idea? I still searched the internet (unsuccessful).
(I work with the pemperature sensor T36)

Thanks a lot for your help, -maybe it's a totally basic thing (being a newbie)?

#define aref_voltage 3.3         // we tie 3.3V to ARef and measure it with a multimeter!
// TMP36 Temperatursensor
 
 
 //RGB LED pins
int ledAnalog[] = {3, 5, 4}; //the three pins of the first analog LED 3 = redPin, 5 = greenPin, 4 = bluePin
//These pins must be PWM

 
 
//TMP36 Pin Variables
int tempPin = 1;        //the analog pin the TMP36's Vout (sense) pin is connected to
                        //the resolution is 10 mV / degree centigrade with a
                        //500 mV offset to allow for negative temperatures
int tempReading;        // the analog reading from the sensor
 
 
 //Defined Colors (different RGB (red, green, blue) values for colors
//(to add your own ie. fuscia experiment and then add to the list)
const byte RED[] = {255, 0, 0};
const byte ORANGE[] = {83, 4, 0};
const byte YELLOW[] = {255, 255, 0};
const byte GREEN[] = {0, 255, 0};
const byte BLUE[] = {0, 0, 255};
const byte INDIGO[] = {4, 0, 19};
const byte VIOLET[] = {23, 0, 22};
const byte CYAN[] = {0, 255, 255};
const byte MAGENTA[] = {255, 0, 255};
const byte WHITE[] = {255, 255, 255};
const byte BLACK[] = {0, 0, 0};
const byte PINK[] = {158, 4, 79};
 
void setup(){
  for(int i = 0; i < 3; i++)
  {
    pinMode(ledAnalog[i], OUTPUT);
    //Set the three LED pins as outputs
  }
  setColor(ledAnalog, BLACK);
  //Turn off led 1
}
 
 
 
 
 
 
 
void setup(void) {
  // We'll send debugging information via the Serial monitor
  Serial.begin(9600);   
 
  // If you want to set the aref to something other than 5v
  analogReference(EXTERNAL);
}
 
 
void loop(void) {
 
  tempReading = analogRead(tempPin);  
 
  Serial.print("Temp reading = ");
  Serial.print(tempReading);     // the raw analog reading
 
  // converting that reading to voltage, which is based off the reference voltage
  float voltage = tempReading * aref_voltage;
  voltage /= 1024.0; 
 
  // print out the voltage
  Serial.print(" - ");
  Serial.print(voltage); Serial.println(" volts");
 
  // now print out the temperature
  float temperatureC = ((voltage - 0.5) * 100)+54.5 ;  //converting from 10 mv per degree wit 500 mV offset
                                               //to degrees ((volatge - 500mV) times 100)
  Serial.print(temperatureC); Serial.println(" degrees C");
 
   // now convert to Fahrenheight
  float temperatureF = (temperatureC * 9.0 / 5.0) + 32.0;
  Serial.print(temperatureF); Serial.println(" degrees F");
 
 
  delay(2000);
  
  
    
   /* Example 1 - Defined Colors
  Set to a known color (you can use any of the above defined colors)*/
 
  
  if (tempReading <= 25);
{
  setColor(ledAnalog, BLUE);
}
else if (tempReading > 25 && tempReader <= 30)
{
  setColor(ledAnalog, ORANGE);
}
else
{
  setColor(ledAnalog, RED
}
  
  
}

I'm sorry for coming with a question for the first post.

You need to tell the compiler what the setColor function that you're calling does. Where did you get the idea of using the setColor function from? It sounds like you need to download a library.

Also, you have two functions both called setup -- you need to combine them.

Hello WizenedEE,
thanks a lot for your reply.
I found the code on:

Also thanks a lot for the 'setup' tip :slight_smile: .

Best,
Constantin

The only code I see on that page is in the comments and in it, he defines the setColor function.

Hello,
I just did some 'try and error'...unfortunately is started to become more curious :smiley: .
The temperature measuring programme (which worked as a single programme pretty good) doesn't work any more - surprisingly I'm not getting any fault/errors while compiling any more. => Looks fine but doesn't work :~ .

Does someone have an idea?

#define aref_voltage 3.3         // we tie 3.3V to ARef and measure it with a multimeter!
// TMP36 Temperatursensor

 //RGB LED pins
int ledAnalog[] = {3, 5, 4}; //the three pins of the first analog LED 3 = redPin, 5 = greenPin, 4 = bluePin
//These pins must be PWM

//TMP36 Pin Variables
int tempPin = 1;        //the analog pin the TMP36's Vout (sense) pin is connected to
                        //the resolution is 10 mV / degree centigrade with a
                        //500 mV offset to allow for negative temperatures
int tempReading;        // the analog reading from the sensor
  
//Defined Colors (different RGB (red, green, blue) values for colors
//(to add your own ie. fuscia experiment and then add to the list)
const byte RED[] = {255, 0, 0};
const byte ORANGE[] = {83, 4, 0};
const byte YELLOW[] = {255, 255, 0};
const byte GREEN[] = {0, 255, 0};
const byte BLUE[] = {0, 0, 255};
const byte INDIGO[] = {4, 0, 19};
const byte VIOLET[] = {23, 0, 22};
const byte CYAN[] = {0, 255, 255};
const byte MAGENTA[] = {255, 0, 255};
const byte WHITE[] = {255, 255, 255};
const byte BLACK[] = {0, 0, 0};
const byte PINK[] = {158, 4, 79};

void setup(void)
  {
  // We'll send debugging information via the Serial monitor
  Serial.begin(9600);   
 
  // If you want to set the aref to something other than 5v
  analogReference(EXTERNAL);
  
  for(int i = 0; i < 3; i++)
  {
  pinMode(ledAnalog[i], OUTPUT);
  //Set the three LED pins as outputs
  }
  setColor(ledAnalog, BLACK);
  //Turn off led 1
  }
 
 void setColor(int* led, const byte* color)
  {
  byte tempByte[] = {color[0], color[1], color[2]};
  setColor(led, tempByte);
  }

void loop(void)
  {
  tempReading = analogRead(tempPin);  
 
  Serial.print("Temp reading = ");
  Serial.print(tempReading);     // the raw analog reading
 
  // converting that reading to voltage, which is based off the reference voltage
  float voltage = tempReading * aref_voltage;
  voltage /= 1024.0; 
 
  // print out the voltage
  Serial.print(" - ");
  Serial.print(voltage); Serial.println(" volts");
 
  // now print out the temperature
  float temperatureC = ((voltage - 0.5) * 100)+54.5 ;  //converting from 10 mv per degree wit 500 mV offset
                                               //to degrees ((volatge - 500mV) times 100)
  Serial.print(temperatureC); Serial.println(" degrees C");
 
   // now convert to Fahrenheight
  float temperatureF = (temperatureC * 9.0 / 5.0) + 32.0;
  Serial.print(temperatureF); Serial.println(" degrees F");
 
  delay(2000);
 

/* Example 1 - Defined Colors
Set to a known color (you can use any of the above defined colors)*/
  
  if (tempReading <= 25)
{
  setColor(ledAnalog, BLUE);
}
else  if (tempReading > 25 && tempReading <= 30)
{
  setColor(ledAnalog, ORANGE);
}
else
{
  setColor(ledAnalog, RED);
}
}
 void setColor(int* led, const byte* color)
  {
  byte tempByte[] = {color[0], color[1], color[2]};
  setColor(led, tempByte);
  }

Recursion inadvisable.

Recursion inadvisable.

It's not really recursive. The original code had two setColor() functions - one taking a byte array and the other taking a const byte array. OP only bothered to copy the byte array version, which is trying to call the const byte version, which really does the useful stuff.

It's not really recursive.

In the absence of an overloaded declaration of "setColor" in the sketch as presented in reply #5 and the absence of any include headers, I'll stick with my hypothesis.

I'll stick with my hypothesis.

No problem. That code has been posted before. OP did a lousy cut/paste job, or failed to type everything. Without the 2nd setColor() function, though, the code will not work, as the call is indeed recursive without it.

I just wanted to say I love the instructables
I'm electric guy!