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.
Test the fade
node with servo
.
Add a servo
next to led
and link it with fade
too.
Bind 2.0 to the RATE
pin to get a faster transition.
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.