Class: BBB::Components::AnalogComponent

Inherits:
Object
  • Object
show all
Includes:
Pinnable
Defined in:
lib/BBB/components/analog_component.rb

Overview

An AnalogComponent is a component that reads from an analog input (AIN) on the board. You can use a generic analog component for, for example, temperature or light sensors.

The BeagleBoneBlack has 12 bit (4096) AIN pins. So the expected value of an analog pin is between 0 and 4096.

Instance Attribute Summary

Attributes included from Pinnable

#pins

Instance Method Summary collapse

Methods included from Pinnable

#after_pin_initialization, included, #initialize_pins, #pinnable?, #verify_pin_position_count

Instance Method Details

#pinObject

Convenience method to grab the first pin in the pins array

Returns:

  • BBB::Pins::AnalogPin



40
41
42
# File 'lib/BBB/components/analog_component.rb', line 40

def pin
  pins.first
end

#readObject

Read from an initialized pin, if the pins have not been initialized yet, this method might actually raise an exception.

Returns:

  • Integer

Raises:

  • MethodNotFoundException



24
25
26
# File 'lib/BBB/components/analog_component.rb', line 24

def read
  pin.read
end

#valueObject

See Also:



31
32
33
# File 'lib/BBB/components/analog_component.rb', line 31

def value
  read
end