Program that configures MCU's timer registers to sample sensor data and output PWM to an HVAC cooling fan
Device: SparkFun Pro Micro 5V/16MHz (Atmega32U4)
Temperature Sensor: DS18B20
Fan: SanAce 92W XF-P05801, DC 24V/1.0A
Voltage Regulator: TRACO THD 12-4812WI, DC 18-75V In, 12V/1000ma Out
https://github.com/milesburton/Arduino-Temperature-Control-Library
https://github.com/PaulStoffregen/OneWire
Make sure your Arduino IDE is setup for uploading code to the SparkFun Pro Micro Board:
The code simply uses the linear mapping function map() to map temperatures to motor speeds
Motor speeds range from 0-100% duty cycle (0-100)
Exposed parameters are defined at the top of the code
MOTOR_MIN, MOTOR_MAX
TEMP_MIN, TEMP_MAX
Error Catching (In both cases, fan is turned off):
When sensor's sense wire is disconnected from MCU
When sensor itself is disconnected from ground and power
Exposed a parameter (SAMPLING_PERIOD) for changing sensor update rate (In miliseconds)