Brightness gradient

6,156
Author: Yisong Xu, Si Xu

The onboard LED lights red and the brightness increase gradually. When the brightness reaches a certain value, the onboard LED turns off. Repeat this process.

Hardware requirements:

mBot/mCore Control Panel

Implementation:

Upload the program to Arduino

Example program download:

Brightness gradient.sb2

download

Effect demo
arduino code

 

Example programs
arduino code

 

Script description

arduino code Define Variable arduino code button  as the brightness value of the red light of the onboard LED.
Set the initial value of Variable arduino code button as 0, and then the onboard LED is initially off.
Set the varied value of Variable arduino code button and the brightness increases by 1 each time
Avoid excessively fast change of the red light. Wait to control its changing speed.
You can adjust the number “60” here and set the maximum brightness the onboard Led can achieve.

This work is licensed under a Creative Commons Attribution-ShareAlike 4.0 International License.

—— More examples