Skip to content

Instantly share code, notes, and snippets.

@staceymakes
Created July 29, 2014 16:14
Show Gist options
  • Select an option

  • Save staceymakes/dfeec09ce4724078d28d to your computer and use it in GitHub Desktop.

Select an option

Save staceymakes/dfeec09ce4724078d28d to your computer and use it in GitHub Desktop.
Spacebrew Processing Connect
import spacebrew.*;
import processing.serial.*;
String server = "sandbox.spacebrew.cc";
String name = "Processing_CLIENT;
String description = "Testing from processing ";
// TAKEN FROM THE SPACEBREW TUTORIAL - JUST MODIFIED TO SIMPLIFY W/O ARDUINO
Spacebrew spacebrewConnection; // Spacebrew connection object
void setup() {
size(400, 200);
// instantiate the spacebrew object
spacebrewConnection = new Spacebrew( this );
// add each thing you publish to
spacebrewConnection.addPublish( "brightness", bright );
// connect to spacebrew
spacebrewConnection.connect(server, name, description );
}
void draw() {
// set backgroun color based on brightness
background( bright / 4, bright / 4, bright / 4 );
// if background is light then make text black
if (bright < 512) { fill(225, 225, 225); }
// otherwise make text white
else { fill(25, 25, 25); }
// set text alignment and font size
textAlign(CENTER);
textSize(16);
if (spacebrewConnection.connected()) {
// print client name to screen
text("Connected as: " + name, width/2, 25 );
// print current bright value to screen
textSize(60);
text(bright, width/2, height/2 + 20);
}
else {
text("Not Connected to Spacebrew", width/2, 25 );
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment