Class: ServoThrottle

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



19
20
21
22
23
24
25
26
27
# File 'lib/examples/servo_throttle.rb', line 19

def loop
  servo_refresh
  #delay 9 # comment out if using servo status, since it will add enough delay
  @sensor_position = analogRead(sensor)
  @servo_amount = (add_hysteresis(@sensor_position, 10)*0.36)
  my_servo.position @servo_amount
  servo_status
  
end

#servo_statusObject



29
30
31
32
33
34
35
36
37
# File 'lib/examples/servo_throttle.rb', line 29

def servo_status
  
 my_lcd.setxy 0,0			# line 0, col 0
my_lcd.print "Read  Send"
my_lcd.setxy 0,1		# line 1, col 0
my_lcd.print @sensor_position # need method of blanking out previous reading
my_lcd.setxy 6,1 
my_lcd.print @servo_amount
end