Class: DebounceMethods
- Inherits:
-
ArduinoSketch
- Object
- ArduinoSketch
- DebounceMethods
- Defined in:
- lib/examples/debounce_methods.rb
Instance Attribute Summary
Attributes inherited from ArduinoSketch
Instance Method Summary collapse
- #blink_three_times ⇒ Object
-
#blink_three_times_basic ⇒ Object
no blink helper.
- #blink_twice ⇒ Object
- #blink_with_a_twist ⇒ Object
-
#loop ⇒ Object
# 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.
Methods inherited from ArduinoSketch
#add, add_to_setup, #array, #assembler, #comment_box, #compose_setup, #define, #delay, #digitalWrite, #formatted_print, #initialize, #input_pin, #input_pins, output_pin, #output_pin, post_process_ruby_to_c_methods, pre_process, #serial_begin
Methods included from ExternalVariableProcessing
#c_type, #check_variable_type, #post_process_arrays, #post_process_vars, #pre_process_vars, #process_external_vars, #translate_variables
Constructor Details
This class inherits a constructor from ArduinoSketch
Instance Method Details
#blink_three_times ⇒ Object
29 30 31 |
# File 'lib/examples/debounce_methods.rb', line 29 def blink_three_times 3.times { led.blink 200 } end |
#blink_three_times_basic ⇒ Object
no blink helper
34 35 36 37 38 39 40 41 |
# File 'lib/examples/debounce_methods.rb', line 34 def blink_three_times_basic 4.times do led.on delay 200 led.off delay 200 end end |
#blink_twice ⇒ Object
23 24 25 26 27 |
# File 'lib/examples/debounce_methods.rb', line 23 def blink_twice 2.times do |i| led.blink 200 + i end end |
#blink_with_a_twist ⇒ Object
43 44 45 46 47 |
# File 'lib/examples/debounce_methods.rb', line 43 def blink_with_a_twist 20.times do |i| led.blink i * 10 end end |
#loop ⇒ Object
# 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
15 16 17 18 19 20 21 |
# File 'lib/examples/debounce_methods.rb', line 15 def loop blink_twice if read_input blink_three_times if read_input .read_and_toggle led # blink_three_times_basic if read_input blink_with_a_twist if read_input end |