//Variables
float tempC;
int tempPin = 1; //Temp sensor is plugged into An0
void setup() {
Serial.begin(9600);
}
void loop() {
// put your main code here, to run repeatedly:
tempC = analogRead(tempPin); // read the analog value from the lm35 sensor.
tempC = (5.0 * tempC * 100.0)/1024.0; // convert the analog input to temperature in centigrade.
Serial.println((byte)tempC);
delay(3000); //3 second delay
}
And I get temps that are 215 degrees celcius or higher. It works for a lot of people and it doesn't for me. What could be wrong? Could I have a defect temperature sensor?
int tempPin = 1; //Temp sensor is plugged into An0
In the circuit you connect to A3, in the comment you say it's A0 and in the code you use A1 (given you're actually using an Arduino UNO). What's true now?
int tempPin = 1; //Temp sensor is plugged into An0
In the circuit you connect to A3, in the comment you say it's A0 and in the code you use A1 (given you're actually using an Arduino UNO). What's true now?
I plugged it into analog pin 1 but never updated the comment in the code.