module Dino
  module Components
    class RgbLed < BaseComponent
      # options = {board: my_board, pins: {red: red_pin, green: green_pin, blue: blue_pin}
      def initialize(options={})
        super(options)

        raise 'missing pins[:red] pin' unless self.pins[:red]
        raise 'missing pins[:green] pin' unless self.pins[:green]
        raise 'missing pins[:blue] pin' unless self.pins[:blue]

        pins.each do |color, pin|
          set_pin_mode(:out, pin)
          analog_write(Board::LOW, pin)
        end
      end

      def blue
        analog_write(Board::HIGH, pins[:red])
        analog_write(Board::HIGH, pins[:green])
        analog_write(Board::LOW, pins[:blue])
      end

      def red
        analog_write(Board::LOW, pins[:red])
        analog_write(Board::HIGH, pins[:green])
        analog_write(Board::HIGH, pins[:blue])
      end

      def blinky
        [Board::HIGH, Board::LOW].cycle do |level|
          analog_write(level, pins[:red])
          analog_write(level, pins[:green])
          analog_write(level, pins[:blue])
          sleep(0.01)
        end
      end
    end
  end
end

module Dino
  module Components
    class RgbLed < BaseComponent
      # options = {board: my_board, pins: {red: red_pin, green: green_pin, blue: blue_pin}
      def initialize(options={})
        super(options)

        raise 'missing pins[:red] pin' unless self.pins[:red]
        raise 'missing pins[:green] pin' unless self.pins[:green]
        raise 'missing pins[:blue] pin' unless self.pins[:blue]

        pins.each do |color, pin|
          set_pin_mode(:out, pin)
          analog_write(Board::LOW, pin)
        end
      end

      def blue
        analog_write(Board::LOW, pins[:red])
        analog_write(Board::LOW, pins[:green])
        analog_write(Board::HIGH, pins[:blue])
      end

      def red
        analog_write(Board::HIGH, pins[:red])
        analog_write(Board::LOW, pins[:green])
        analog_write(Board::LOW, pins[:blue])
      end

      def green
        analog_write(Board::LOW, pins[:red])
        analog_write(Board::HIGH, pins[:green])
        analog_write(Board::LOW, pins[:blue])
      end

      def blinky
        [Board::HIGH, Board::LOW].cycle do |level|
          analog_write(level, pins[:red])
          analog_write(level, pins[:green])
          analog_write(level, pins[:blue])
          sleep(0.01)
        end
      end
    end
  end
end

Fix RGB LED component to turn on the right colors
Fix RGB LED component to turn on the right colors