# File lib/examples/debounce_methods.rb, line 29 def blink_three_times 3.times { led.blink 200 } end
no blink helper
# File lib/examples/debounce_methods.rb, line 34 def blink_three_times_basic 4.times do led.digitalWrite HIGH delay 200 led.digitalWrite LOW delay 200 end end
# File lib/examples/debounce_methods.rb, line 23 def blink_twice 2.times do |i| led.blink 200 + i end end
# File lib/examples/debounce_methods.rb, line 43 def blink_with_a_twist 20.times do |i| led.blink i * 10 end end
depressing and releasing button_one, button_two or button_four do the same thing with a slightly different syntax and number of blinks button_three simply toggles the led with the read_and_toggle method button_five does it with a twist
# File lib/examples/debounce_methods.rb, line 15 def loop blink_twice if read_input button_one blink_three_times if read_input button_two button_three.read_and_toggle led # blink_three_times_basic if read_input button_four blink_with_a_twist if read_input button_five end