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.

Buttons

Screenshot of 104-button

Here is a button node from xod/common-hardware.

Take a look at button outputs. It has a PRS pin, which is true whenever it is pressed. On each UPD input pulse either of output pulses is emitted:

  • DONE if the reading is done, wherever the button is pressed or not
  • ERR if the reading of hardware port is impossible, for example, the incorrect port number defined in the PORT pin

This is a standard idiom for side-effect nodes representing hardware or, for example, the Internet.

Circuit

Assembling button to Uno

↓ Download as a Fritzing project

Exercise

Let’s make the LED glow while the button is pressed.

  1. Assemble the circuit with a button and LED.
  2. Set the PORT value of the button node.
  3. Link PRS to LUM.
  4. Upload your patch.

Hold the button to turn the LED on.

Additional exercise

Place the already familiar node flip-flop between button and led to switch the LED on or off on each press.

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.