Quantcast
Channel: Arduino Forum - Latest topics
Viewing all articles
Browse latest Browse all 15622

A problem in getting values

$
0
0

I was trying to build a thermometer that changed the color of an RGB Led based on the value taken from a standard (starter kit) TMP sensor. Tghe value never got below "130" and never over "160". I found a smooth formula to change the value of red and blue based on the temp.

const int redPin = 6;
const int greenPin = 3;
const int bluePin = 5;
const int tempReadPin = A0;

int redValue = 0;
int greenValue = 0;
int blueValue = 0;
int tempRead = 0;

void setup() {
  Serial.begin(9600);
  pinMode(6, OUTPUT);
  pinMode(5, OUTPUT);
  pinMode(3, OUTPUT);
  
}

void loop() {
  tempRead = analogRead(tempReadPin);
  Serial.print(tempRead);
  greenValue = tempRead;
  blueValue = 255/1+(2.71828)pow(-0.1(tempRead-145));
  redValue =-(255/(1+(2.71828)pow(-0.1(tempRead-145))+255);
  Serial.print(",   red: ");
  Serial.print(redValue);
  Serial.print(",   blue: ");
  Serial.println(blueValue);
  delay(500);
  if (redValue>0) {
    if (blueValue>0) {
      analogWrite(bluePin, blueValue);
      analogWrite(redPin, redValue);
      }
    }
  }

The :
"
blueValue = 255/1+(2.71828)pow(-0.1(tempRead-145));
redValue =-(255/(1+(2.71828)pow(-0.1(tempRead-145))+255);
"
Keeps giving me the error:
"
In function 'void loop()':
23:30: error: expected ';' before 'pow'
24:31: error: expected ')' before 'pow'
24:59: error: expected ')' before ';' token
"
What have I done wrong?

4 posts - 2 participants

Read full topic


Viewing all articles
Browse latest Browse all 15622

Latest Images

Trending Articles



Latest Images