powered by TinkerSpace.in
Join free
TinkerPy Projects lessons
🌗
Lesson 3 of 10 · Starter · 10 min

Bright and dim

Use numbers from 0 to 100 to set brightness, and make a smooth fade.

pwm() can be any number from 0 to 100. pwm(100) is full power, pwm(50) is half, pwm(10) is a tiny glow.

TinkerPy
setup:

loop:
    o1 = pwm(100)
    wait(1000)
    o1 = pwm(50)
    wait(1000)
    o1 = pwm(10)
    wait(1000)
Bright, medium, dim.

A smooth fade

output_increment_till(o1, 0, 100, 5, 50) climbs from 0 to 100 in steps of 5, waiting 50 ms between steps. output_decrement_till goes back down.

TinkerPy
setup:

loop:
    output_increment_till(o1, 0, 100, 5, 50)
    output_decrement_till(o1, 100, 0, 5, 50)
A “breathing” light.
🚀 Your turn

Make the fade slower by changing the last number from 50 to 100.