Help with writing a program to control a temperature sensor
I am new to Arduino and would like some help writing a program to control a temperature sensor with two push button switches (normally open).
A temperature sensor will be connected to an analogue input pin A0. A heater will be controlled by PWM using pin 11. A relay to completely remove power from the heater circuit will be controlled by pin 1. A 16 X 2 LCD display will be used to display the set-point temperature , the actual temperature, the on/off mode and the duty cycle of the heater output. Start and Stop pushbuttons connected to pins 2 and 3 will be used to start and stop the process. These two pins are to initiate a hardware interrupt where the system is either started or stopped within the interrupt routine.
Another two inputs are used to increase or decrease the set-point temperature while the program is running. The set-point is incremented or decremented by 1 for each operation of these inputs. The lower set-point value is to be limited to 25 Degrees C and the upper limit is to be 45 Degrees C.
The temperature sensor has an output of 10mV / Degrees C. Where 0 Degrees C will have an input of 0V and 100 Degrees C will have an input of 1V. These voltages relate to a binary number range of 0 to 204. You will have to manipulate these values to numbers that represent the actual temperature being measured.
The duty cycle of the output controlling the temperature should be at 100% when the actual temperature is 5 Degrees C or more less than the set-point. As the temperature approaches the set-point temperature, the duty cycle is to reduce by 20% for each degree closer to the set-point.
e.g. At 4 Degrees C less than the set-point, the Duty Cycle = 80%
At 3 Degrees C less than the set-point, the Duty Cycle = 60%
At 2 Degrees C less than the set-point, the Duty Cycle = 40%
At 1 Degrees C less than the set-point, the Duty Cycle = 20%
When the temperature equals the set-point, the Duty Cycle = 0%
When the process is started, a relay supplies power to the heater and will energize and stay on until
the stop button is pressed. Use a separate function for each of the following tasks:
- Reading the analogue input and manipulating the value to a number that represents the actual temperature.
- Calculating the heater duty cycle.
- Incrementing and decrementing the set-point value.
- Displaying data on the LCD.
- Starting and Stopping the process (interrupt routine).
Temperature sensor pin A0
Start pushbutton pin 2
Stop pushbutton pin 3
PWM (mosfet) pin 11
Relay pin 0
LCD pins 5 to 10
Thanks for your insights!