Giter Club home page Giter Club logo

scratch2sphero's Introduction

Scratch2Sphero

With Scratch2Sphero, you can control Sphero 2.0 from Scratch 1.4. Tested on MacOS X(10.8.5, 10.9, and 10.9.1).

Requirements

Installation

% git clone https://github.com/champierre/scratch2sphero.git
% bundle install

or

% git clone https://github.com/champierre/scratch2sphero.git
% ('sudo' if necessary) xcode-select --install # optional step depending on the state of your development tools.  if you get errors building the gems, try this
% ('sudo' if necessary) gem install hybridgroup-serialport
% ('sudo' if necessary) gem install sphero

If you cannot use git, you can download the source code from "Download ZIP" button appeared on the right side of the README page.

Getting Started

Getting Scratch and Sphero to talk to each other on your Mac

  1. Pair your computer with your Sphero. Do this via the Bluetooth pane in settings. Remember, it can only be paired to one device at a time, so turn off bluetooth on any other devices you might be using.
  2. On Scratch, right-click on the () Sensor Value block, found in the Sensing category, and select the "Enable remote sensor connections" option.
  3. On the terminal, run scratch2sphero.rb. You can then monitor this terminal window for any debug information.

Movement

  1. Use Scratch variable "steps" and Broadcast "move" to make Sphero roll. The number set for "steps" is the duration that Sphero keeps moving.
  2. Use Scratch variable "degrees" and Broadcast "turn" to make Sphero turn. The number set for "degrees" is the degree that Sphero turns.
  3. (Alternative) Use Broadcast backward/forward/left/right block, found in the Control category, to make Sphero roll to the direction specified.
  4. You can use the following Scratch variables to change the behavior of Sphero.
  • speed(default: 20) - roll speed
  • initial_heading(default: 0) - initial heading in degree

LED Control

Back LED

To help your users know which direction the ball is facing, you might want to toggle the back LED

  • Use the "back_led_on" broadcast to turn on the little light to tell you were the back of the ball is
  • Use the "back_led_off" broadcast to turn the light off

Color

Who doesn't like rainbows? Especially blinking double rainbows. You can control the main LED color of Sphero via the color broadcast.

  • create a global variable named color_name and assign it a color name, then broadcast "color".
  • you can also define new broadcasts with color_name where name is one of the valid color names, e.g. broadcast "color_cadetblue" or broadcast "color_crimson"
  • if you send it an invalid, or blank, color name, it will restore to the saved default color for your Sphero

Demo Scripts

Sphero draws square

Sphero draws square

Sphero makes a rainbow

Sphero Colors

Demo Movies

Scratch x Sphero

Sphero 2.0 controlled by Scratch(Japanese + English caption)

Sphero colors via Scratch

Additional Resources

scratch2sphero's People

Contributors

champierre avatar chrisnolan avatar jameswilliamiii avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.