This page has no translation to 中文 yet. The original English version is below. If you’d like to help, great! See how to translate a documentation page in the contribution guide.
Note This is a web-version of a tutorial chapter embedded right into the XOD IDE. To get a better learning experience we recommend to install the desktop IDE or start the browser-based IDE, and you’ll see the same tutorial there.

Alarm

Screenshot of 202-alarm

Here is the program of a simple alarm device, which turns the LED on when the temperature gets higher than the desired value.

As you can note, we use the greater node, one of the comparison nodes from the XOD standard library.

Exercise #

Change the logic to make the alarm working whenever the temperature gets lower than the threshold. Let the user to set this value using a potentiometer.

  1. Replace the greater node with less.

  2. Place the map node and bind values to map 0.0…1.0 range to 15…30 degrees Celsius.

  3. Place pot and bind the corresponding PORT.

  4. Link pot, map, and less nodes.

  5. Upload the program.

Rotate the potentiometer knob to set the threshold. Heat and cool down the thermometer to see how it works.

Additional exercise #

Use both greater and less nodes to alarm only when the temperature is out of the range. Hint: you need the or node.

Found a typo or mistake? Want to improve the text? Edit this page on GitHub and open a pull request. If you have a complex proposal or you want to discuss the content, feel free to start a new thread on XOD forum.