Class: FirstSound

Inherits:
ArduinoSketch show all
Defined in:
lib/examples/first_sound.rb

Instance Attribute Summary

Attributes inherited from ArduinoSketch

#pins

Instance Method Summary collapse

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

#loopObject



7
8
9
10
11
12
# File 'lib/examples/first_sound.rb', line 7

def loop
    myTone.disable
    1.upto(400) { |x| tone_out x }   # run up the scale to 4000 Hz in 10 Hz steps
    399.downto(1) { |x| tone_out x } # come back down in 10 Hz steps
    delay 2000
end

#tone_out(n) ⇒ Object



14
15
16
17
18
19
20
# File 'lib/examples/first_sound.rb', line 14

def tone_out(n)
    myTone.set_frequency 10*n
    myTone.enable
    delay 80
    myTone.disable
    delay 10
end