Class: IoT::BinaryReceptor

Inherits:
Receptor show all
Defined in:
lib/iot/binary_receptor.rb

Overview

BinaryReceptor - receptor/actuator with binary logic

Direct Known Subclasses

BinarySensor, Button

Instance Method Summary collapse

Methods inherited from Receptor

#model_name, #name, #read

Constructor Details

#initialize(pin = 21, pull = :up) ⇒ BinaryReceptor

Returns a new instance of BinaryReceptor.



7
8
9
10
# File 'lib/iot/binary_receptor.rb', line 7

def initialize(pin=21, pull=:up)
  @pin = pin
  RPi::GPIO.setup pin, :as => :input, :pull => pull
end

Instance Method Details

#high?Boolean

Returns:

  • (Boolean)


12
13
14
# File 'lib/iot/binary_receptor.rb', line 12

def high?
  RPi::GPIO.high? @pin
end

#low?Boolean

Returns:

  • (Boolean)


16
17
18
# File 'lib/iot/binary_receptor.rb', line 16

def low?
  RPi::GPIO.low? @pin
end