I have a project that controls a fan if the temperature rises above something
The problem is that the potentiometer interferes with the temperature reading.
I have a 4.7k pot and an lm35bt temp sensor.
The code:
#include <Wire.h>
#include <LiquidCrystal_I2C.h>
float temp;
int tempPin = A1;
LiquidCrystal_I2C lcd(0x27,20,4); // set the LCD address to 0x27 for a 16 chars and 2 line display
void setup()
{
Serial.begin(9600);
lcd.init(); // initialize the lcd
// Print a message to the LCD.
lcd.backlight();
}
void loop()
{
temp = analogRead(tempPin);
// read analog volt from sensor and save to variable temp
temp = temp * 0.48828125;
// convert the analog volt to its temperature equivalent
int set = map(analogRead(A2), 0, 1023, 20, 66);
lcd.setCursor(0,0);
lcd.print("Temp: ");
lcd.print(temp);
lcd.setCursor(0,1);
lcd.print("Set Temp: ");
lcd.print(set);
delay(10);
}
And please be English friendly, I don't know much.
Try to add additional "empty" analogRead before each use. Like:
analogRead(tempPin);
temp = analogRead(tempPin);
// read analog volt from sensor and save to variable temp
temp = temp * 0.48828125;
// convert the analog volt to its temperature equivalent
analogRead(A2);
int set = map(analogRead(A2), 0, 1023, 20, 66);
if it really interferes it is a hardware-issue.
Anyway you should post a picture with a handdrawn schematic that shows how you have connected the LM35 and the potentiometer to the Arduino.