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.

Fade

Screenshot of 206-fade

Here is a program with the LED that turns on smoothly while the button is pressed.

To make a smooth transition from 0 to 1 and vice versa we use the fade node from the XOD standard library. It transforms its output value toward the target value with the rate specified.

In some cases this node helps to reduce bouncing or power bursts. For example, when you rotate a motor without smooth acceleration, it can cause a voltage drop and whole device reboot.

Exercise

Test the fade node with servo.

  1. Add a servo next to led and link it with fade too.

  2. Bind 2.0 to the RATE pin to get a faster transition.

  3. Upload the program.

Press and hold the button a few times. Observe how fade smoothens the transition and changes the direction if the re-targeted in the middle of the process.

Remove the fade node, link to button directly, and take a look at the board. When the motor starts moving you can see board LEDs are dimming; the board even can reboot.

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.