Class: HelloSpectraSound

Inherits:
ArduinoSketch show all
Defined in:
lib/examples/hello_spectra_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



24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/examples/hello_spectra_sound.rb', line 24

def loop
  my_lcd.setxy 0,1
  # since lcd's have issues clearing tens and hundreds digits when reading ones, 
  # we use pad_int_to_str, which is a hack to display these cleanly
  # pad_int_to_str takes two arguments: an integer and the final string length
  # 
#     my_lcd.print pad_int_to_str analogRead(sensor_one), 5
  @reading = sensor_one.soft_lock
  sound.set_frequency @reading * 10
  my_lcd.print pad_int_to_str @reading, 3
  delay 30
end

#setupObject



16
17
18
19
20
21
22
# File 'lib/examples/hello_spectra_sound.rb', line 16

def setup
  delay 1000
  my_lcd.setxy 0,0, "spectra symbol"
  my_lcd.setxy 0,1, "soft pot sound"
  delay 3000
  my_lcd.clearscr
end