Help for arduino program code

Hello!

First I want to apologize for my bad english :blush:

I want to ask you to help me find any source code for Control Relay with Thermal sensor.

example:

have a liquid and a heater and a relay to control the heater. example, and want to reach the 30 degree temperature and the heater relay to turn off then a fall in temperature of the liquid temperature up to 15 degrees to relay heater became involved and this process is repeated.

I'd be most grateful if you help me :)

No one is going to write code for you.

You can search LM35 temperature sensor ic.

ir produces 10mv per degree. read it with analog input & compare it.

I hope it helps.

Roshani

The Arduino will not drive a relay directly so you will need a driver circuit between the Arduino and the relay. That could be a simple transistor circuit, or some other form of driver circuit bought off the shelf, such as a relay shield.

There is a ‘Motors, Mechanics, and Power’ section of the forum dedicated to this subject and if you need help with that you should look there.

You will also need to connect the temperature sensor a read values from it. There is a wide selection of digital and analog temperature sensors and you should have no trouble finding examples of reading values from each one. I prefer the DS18B20 digital sensor since it is easy to use and gives accurate readings without having to worry about calibration, but there are plenty of alternatives.

Once you know how to read the temperature and control the relay, the code to switch the relay by comparing the temperature against two thresholds is trivial.

if(temperature() < LOW_THRESHOLD)
{
  heaterOn();
}
else if(temperature() > HIGH_THRESHOLD)
{
  heaterOff();
}

Here temperature(), heaterOn() and heaterOff() are functions that you would write to carry out these actions.

And could you tell me how to write in certain degrees to switch on and off a pin? Example: At 90 degrees to exclude eg as in this code

if (val2 == HIGH) { 
digitalWrite(ledPin, LOW);

, however, it works for me a certain degree of

The way you write those functions, I think will depend on how you getting the Temp info from Arduino.