You already made a blinking LED and controlled it in the interactive session. But you have only feed it with the values of true and false. The false value auto-converts to 0 and represents no glow at all, whereas the true value converts to 1 and denotes the full brightness.
You can also set an intermediate brightness level by setting values between 0 and 1.
↓ Download as a Fritzing project
Let’s fine-tune LED brightness.
Assemble a circuit according to the scheme, and connect the board to your computer.
Set the value of the PORT
pin to D11
. Leading “D” means that it’s a digital port.
Replace the tweak-boolean
node with tweak-number
.
Upload the program with the interactive session enabled.
Change the value of tweak-number
in the range from 0 to 1 and see how the brightness of the LED changes.
An LED can change the brightness only if connected to a board pin which supports PWM. If you have an Arduino board, find out the port number with the leading “~” symbol.
Many board models have no PWM on D13, so we wire the LED to another pin.