class Fixnum

helpful conversions

Public Instance Methods

to_pwm() click to toggle source

convert to PWM value from analog reading

# File lib/artoo/ext/numeric.rb, line 19
def to_pwm
  ((255.0 / 1023.0) * self.to_f).round
end
to_pwm_reverse() click to toggle source

convert to PWM value from analog reading

# File lib/artoo/ext/numeric.rb, line 24
def to_pwm_reverse
  ((255.0 / 1023.0) * (1023 - self.to_f)).round
end