0.01
Repository is archived
No commit activity in last 3 years
No release in over 3 years
Classes to easily talk to the cloudBit and Arduino module
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

~> 1.7
~> 10.0
>= 0

Runtime

 Project Readme

Build Status

LittleBits Ruby Gem

A Ruby Gem for communicating with littleBits modules.

Currently supported are:

Requirements

Installation

Add this line to your application's Gemfile:

gem 'little_bits'

And then execute:

$ bundle

Or install it yourself as:

$ gem install little_bits

Usage

cloudBit

You'll need the Access Token and Device ID from the Settings page of the littleBits CloudBit Control Panel

You can then start up irb or create a script with the following code:

require 'little_bits'

cloud_bit = LittleBits::CloudBit.new('your-access-token', 'your-device-id')

# Set output to 100% for 3 seconds (3000 milliseconds)
cloud_bit.output(100, 3000)

# Set output to 50% indefinitely (-1 for duration)
cloud_Bit.output(50, -1)

Method Arguments

The first argument is the percentage which should be between 0 and 100.

The second argument is the duration which should be between 0 and 32000. You can send -1 if you want the duration to be indefinite.

Arduino Module

First, follow the littleBits Arduino Module Getting Started Guide to set up your Arduino module.

You'll need to know the serial port that the Arduino is plugged into.

You'll also need to load the StandardFirmata sketch onto your Arduino Module:

  • Start the Arduino IDE
  • Plug in a USB cable from your computer to the Arduino Module
  • Select the serial port your Arduino is on from Tools > Serial Port
  • Switch to the Arduino Leonardo board by clicking on the Tools menu, then Board > Arduino Leonardo
  • Select the File menu, then Example > Firmata > Standard Firmata
  • Select the File menu, then Upload

You can then start up irb or create a Ruby script with the following code:

require 'little_bits'

arduino_module = LittleBits::ArduinoModule.new('/your/serial_port')

# Turn on d1
arduino_module.d1(true)

# Set d5 to max output
arduino_module.d5(255)

# Set d9 to min output
arduino_module.d9(0)

Method Arguments

The d1 method can be sent true or false.

The d5 and d9 methods can be sent true, false, or a number between 0 and 255.

Contributing

  1. Fork it ( https://github.com/spilth/little_bits/fork )
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create a new Pull Request