Hi,
I'm using a tmp36 sensor and 3 LED to show temperature changes in degrees Celsius and Fahrenheit. This is my first time exposed to coding and arduino and I have done the Blink assignment but this one is a little more complex for me. I think I have the structure correct but I keep getting errors like initializer expected before "C" or did not define C but I already looked up examples and the arduino forum and none have these defined in the setup. Any help at all or guidance towards a similar code to mine would be of great help.
This is my code
void setup()
{
int temperaturePin= A0; // This is my pin with the sensor
int ledPin1 = 9; // Pin with Led 1
int ledPin2 = 10; // Pin with Led 2
int ledPin3 = 11; // Pin with Led3
pinMode(ledPin1,OUTPUT); // will outpute voltage value for pin 1
pinMode(ledPin2,OUTPUT); // will output voltage for pin2
pinMode(ledPin3,OUTPUT); // will ouput voltage for pin3
int base= 20;
}
void loop () // will run over and over again
{
float voltage ;
Serial.print(voltage);
Serial.println("voltage");
degrees C= (voltage-0.5)*100; // converts voltage to celsius
float degrees C=20 ;
Serial.print("degrees C");
Serial.println(degrees C);
degrees F= (degrees*9.0/5.0)+32; //converts to Farenheit
float degrees F;
Serial.print(degrees F);
Serial.println("degrees F");
if (degrees C > base && degrees C< base +2 );
{
digitalWrite(ledPin1,HIGH);
digitalWrite(ledPin2,LOW);
digitalWrite(ledPin3,LOW);
}
else if(degrees C> base +2 && degrees C < base+4 );
{
digitalWrite(ledPin1,HIGH);
digitalWrite(ledPin2,HIGH);
digitalWrite(ledPin3,LOW);
}
else if (degrees C >= base+4 && < base+6 )
{
digitalWrite(ledPin1,HIGH);
digitalWrite(ledPin2,HIGH);
digitalWrite(ledPin3,HIGH);
}
float getVoltage( int temperaturePin)
{
return(int temperaturePin * 0.0048);
delay(2000);
}
}
Thank you for even looking at this post!