Adding a Potentiometer to change a value

Hello, I am new to arduino and coding, I was wondering how would i use a potentiometer to adjust the value of celsius and print it to the LCD and have that value become the new threshold.

#include <LiquidCrystal.h>
int reading = 0;
int sensorPin = A0;
int relay =7;

LiquidCrystal lcd(12, 11, 5, 4, 3, 2);

void setup() {

lcd.begin(16, 2);
pinMode(relay,OUTPUT);
}

void loop() {
reading = analogRead(sensorPin);
int celsius = reading/2;
lcd.setCursor(0, 0);
lcd.print("Temperature: ");
lcd.setCursor(0,1);
lcd.print(celsius, DEC);
lcd.print((char)223);
lcd.print(“C”);
if (celsius >35) {
digitalWrite(7,HIGH);

} else {
digitalWrite(7,LOW);
}
delay(500);
lcd.clear();
}

are you asking how to add a pot to calibrate a temp reading or are you asking how to add a pot to act as a setpoint for the relay?

Welcome to the Forum. Please read the two posts by Nick Gammon on guidelines for posting to this Forum, especially the use of code tags ("</>") for code listings. Then, see if this helps:

gpop1: are you asking how to add a pot to calibrate a temp reading or are you asking how to add a pot to act as a setpoint for the relay?

I am asking how to calibrate the temp reading with a pot, any ideas on how i do it?

thank you

Something like this perhaps

void loop() {
   reading = analogRead(sensorPin);
   threshold = analogRead(potPin);   //  <----- new
   int celsius = reading/2;
   // etc

…R

do you have a temp sensor hooked up to A0 as ive never seen a sensor that works by just dividing the analog input by 2 to get temp in c or are you just bench testing a idea?

if you do what is the type/number of the sensor

sorry i forgot to mention that, yeah i am im using a LM35 temp sensor,but i want to make the threshold adjustable with a pot and have it printed to the lcd.

link to the tutorial i followed:

http://www.electroschematics.com/8998/arduino-temperature-controlled-relay/

for the lm35 ive always used

temp = (5.0 * analogRead(tempPin) * 100.0) / 1024; // 5 is the voltage of the board 1024 is the int max

what robin posted will work but will be a pain to compare later

threshold = analogRead(potPin); // <----- new

threshold will now be between 0-1024

look at using the map to change the 0-1024 to 0-50c (search for map example on arduino site)

int val = map(threshold, 0, 1023, 0, 50);// might be wrong but it looks right

val should now be between 0-50

then change your code to compare temp against val

if (celsius >val)

p.s my coding is bad so check and research what I have written is correct