pwm() can be any number from 0 to 100. pwm(100) is full power, pwm(50) is half, pwm(10) is a tiny glow.
from tinkerpy_mega import * def setup(): pass # your code goes here def loop(): write_output(o1, pwm(100)) wait(1000) write_output(o1, pwm(50)) wait(1000) write_output(o1, pwm(10)) wait(1000)
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.
from tinkerpy_mega import * def setup(): pass # your code goes here def loop(): output_increment_till(o1, 0, 100, 5, 50) output_decrement_till(o1, 100, 0, 5, 50)
๐ Your turn
Make the fade slower by changing the last number from 50 to 100.