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
}
}