Drivers

Artoo has a extensible system for connecting to hardware devices.

LED


Allows user to interact with LEDs through digital output and PWM (Pulse Width Modulation)

How To Connect

For Arduino:

require 'artoo'
connection :arduino, :adaptor => :firmata, :port => '127.0.0.1:8023'
device :led, :driver => :led, :pin => 13

For Digispark:

require 'artoo'
connection :digispark, :adaptor => :littlewire, :vendor => 0x1781, :product => 0x0c9f
device :led, :driver => :led, :pin => 13

How To Use

Example using a button to turn a LED on and off.

require 'artoo'

#connection :arduino, :adaptor => :firmata, :port => '/dev/tty*'
connection :arduino, :adaptor => :firmata, :port => '127.0.0.1:8023'
device :led, :driver => :led, :pin => 13

work do
  every 1.second do
    led.on? ? led.off : led.on
  end
end

Commands

on

Turns LED on.

Params

no params

Returns

true or nil

off

Turns LED off.

Params

no params

Returns

true or nil

on?

Returns true if LED is on, otherwise returns false.

Params

no params

Returns

true or false

off?

Returns true if LED is off, otherwise returns false.

Params

no params

Returns

true or false

toggle

Turns the LED on, or off, depending on if it is already off, or on, respectively.

Params

no params

Returns

true or nil

brightness(brightness_int)

Sets brightness of the led to the specified brightness value passed to brightness(brightness_int) using PWM, brightness can be any integer value between 0 and 255.

Params
  • brightness_int - params , the brightness value
Returns

true or nil

Circuit

Compatibility

Important Note: You need to install pi-blaster in the raspberry-pi, this project enables PWM in the GPIO pins .