Sha256: 614bcf454678b41688a7b012e5b8efbec2886a06244b3287778d260de59e8f98
Contents?: true
Size: 793 Bytes
Versions: 7
Compression:
Stored size: 793 Bytes
Contents
require 'artoo/drivers/driver' module Artoo module Drivers # The LED driver behaviors class Led < Driver def is_on? (@is_on ||= false) == true end def is_off? (@is_on ||= false) == false end def on @is_on = true connection.set_pin_mode(pin, Firmata::Board::OUTPUT) connection.digital_write(pin, Firmata::Board::HIGH) end def off @is_on = false connection.set_pin_mode(pin, Firmata::Board::OUTPUT) connection.digital_write(pin, Firmata::Board::LOW) end def toggle is_off? ? on : off end def brightness(level=0) connection.set_pin_mode(pin, Firmata::Board::PWM) connection.analog_write(pin, level) end end end end
Version data entries
7 entries across 7 versions & 1 rubygems