Sha256: 8942f5614f193fad8c76ac0240f40f5b38e2e52ffb131ca4e06ba74c70d209d9
Contents?: true
Size: 993 Bytes
Versions: 7
Compression:
Stored size: 993 Bytes
Contents
module Denko module Motor class L298 include Behaviors::MultiPin attr_reader :speed def initialize_pins(options={}) proxy_pin :direction1, DigitalIO::Output proxy_pin :direction2, DigitalIO::Output proxy_pin :enable, PulseIO::PWMOutput end def after_initialize(options={}) off end def speed=(value) enable.write(value) @speed = value end def forward(value=nil) direction1.high direction2.low self.speed = value if value end def reverse(value=nil) direction1.low direction2.high self.speed = value if value end def idle direction1.low direction2.low self.speed = 0 end alias :off :idle def brake direction1.high direction2.high self.speed = board.pwm_high end end end end
Version data entries
7 entries across 7 versions & 1 rubygems