Home / Series / The Ben Heck Show / Aired Order / Season 0 / Episode 50

The Learning Circuit 16 - Temperature Activated Fan!

DaftMike built a thermometer using an Arduino and a thermistor. He expands on this to show you how to build a temperature controlled fan for your desk. It monitors the room temperature to see if it gets too hot. When it's too hot, an Arduino turns on a fan that cools you off! DaftMike goes over the code from last time. It reads a thermistor and prints the temperature to the serial monitor. He moves all the equations he wrote earlier into four separate functions. A function is like its own little program. In Arduino code there is always a setup and a loop function. The setup is at the start and only runs once. The loop comes after that and repeats continuously. Taking the equations from last time, he re-writes them so that they each have their own separate function. The main loop uses these functions to execute the code. Structuring your program this way makes it easier for you to reuse parts of your code. For example, if you wanted to add another temperature sensor then all you would need to do is call these functions again and pass them a different value. It saves you time as well as some program memory. For it to work, he’ll need to add a couple more functions. One for turning the fan on and one for turning the fan off. He’ll also need to set up the built-in LED as an output to stand in for the fan during testing. When that is done, he tests the code. After testing the code, he notice that when the temperature gets close to the trigger point it flashes. This is not what he wants. The way to fix this is to add what’s called hysteresis. Hysteresis is the dependence of the state of a system on its history. It’s when the output of your system, in this case the fan or the LED for now, lags behind the state of your input, which in this case is the room temperature. Returning to the code, instead of a single trigger point, he’s set some thresholds to check. There’s a high threshold and a low threshold. As long as one number is lower

English
  • Originally Aired July 18, 2018
  • Runtime 17 minutes
  • Network element14
  • Created July 18, 2018 by
    Administrator admin
  • Modified July 18, 2018 by
    Administrator admin