Sha256: ba974945667583d99737f2fe076ca403905f9de1b7e70bbce0b7d3358433bc30

Contents?: true

Size: 1.76 KB

Versions: 4

Compression:

Stored size: 1.76 KB

Contents

class DebounceMethods < ArduinoSketch
  
  # IMPORTANT -- This is one for four examples that fails with Ruby 1.9 support (latest ruby2c and parsetree)
  # the failing example is commented out and replaced with this hello world until I have a chance to resolve the issue -- jd
  output_pin 13, :as => :led

  def loop
    blink led, 100 
    x = 4
  end
  
  ##
  
  # output_pin 13, :as => :led 
  # input_pin 6, :as => :button_one, :device => :button # can also :adjust => 300
  # input_pin 7, :as => :button_two, :device => :button
  # input_pin 8, :as => :button_three, :device => :button
  # input_pin 9, :as => :button_four, :device => :button  
  # input_pin 10, :as => :button_five, :device => :button  
  # 
  # # 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
  # 
  #    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
  #    
  #    def blink_twice
  #       2.times do |i|
  #         led.blink 200 + i
  #       end
  #     end
  #    
  #    def blink_three_times
  #      3.times { led.blink 200 }
  #    end
  # 
  #    # no blink helper
  #    def blink_three_times_basic
  #      4.times do 
  #        led.digitalWrite HIGH
  #        delay 200
  #        led.digitalWrite LOW
  #        delay 200
  #      end
  #    end
  #    
  #    def blink_with_a_twist
  #      20.times do |i|
  #        led.blink i * 10
  #      end
  #    end     
     
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
madrona-rad-0.3.4 lib/examples/debounce_methods.rb
madrona-rad-0.3.5 lib/examples/debounce_methods.rb
madrona-rad-0.3.6 lib/examples/debounce_methods.rb
madrona-rad-0.3.7 lib/examples/debounce_methods.rb