Skip to content

Instantly share code, notes, and snippets.

require 'rubygems'
require 'midiator'
include MIDIator::Notes
# don't ask, just be a good sheep..
# http://www.ruby-forum.com/topic/123503
Kernel::require "serialport.so"
#params for serial port
port_str = "/dev/tty.usbserial-A6006eSL" #may be different for you
/*
sends serial data over usb to be converted by ruby to MIDI..
*/
void setup() {
Serial.begin(9600);
}
require 'widgets/slider_widget'
Shoes.app(:title => "slider test", :width => 200, :height => 250) do
stack do
slider do |pos|
@t.text = "pos: #{pos}"
end
end
stack do
class TuioAnimation
def initialize
@client = TuioClient.new
end
def nextFrame(view)
@client.tuio_cursors.each do |id, cursor|
view.do_something_with_cursor(cursor.x_pos)
end
end
require 'yaml'
YAML.load "{product_id: 4000-00-02}"
# SketchUp sockets are horrible
# try this out, but i get a random amount of garbage on the ends of the strings
# when it reaches SketchUp
require "socket"
gs = TCPserver.open(3333)
addr = gs.addr
addr.shift # removes "AF_INET"
printf("server is on %s\n", addr.join(":"))
# Show the Ruby Console at startup so we can
# see any programming errors we may make.
Sketchup.send_action "showRubyPanel:"
# This is an example of a simple animation that floats the camera up to
# a z position of 200". The only required method for an animation is
# nextFrame. It is called whenever you need to show the next frame of
# the animation. If nextFrame returns false, the animation will stop.
def self.new_with_time( address, time, tags=nil, *args )
message = new( address, tags, *args )
message.time = time
message
end
def initialize(address, tags=nil, *args)
require 'rubygems'
require 'eventmachine'
require File.join( File.dirname( __FILE__), '..', 'osc-ruby')
module OSC
Channel = EM::Channel.new
class Connection < EventMachine::Connection
#include <Servo.h>
Servo my_servo; // create servo object to control a servo
int servo_angle = 0;
int sensor_pin = 2;
int servo_pin = 9;
int scan_values[180];