Skip to content

Instantly share code, notes, and snippets.

@moxuse
Created May 27, 2013 03:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save moxuse/5654995 to your computer and use it in GitHub Desktop.
Save moxuse/5654995 to your computer and use it in GitHub Desktop.
// import UDP library
import hypermedia.net.*;
UDP udp;
void setup() {
udp = new UDP( this, 3054 ); //port from xbee wi-fi
udp.listen( true );
}
void draw() {;}
void keyPressed() {
String message = str( key );
String ip = "localhost";
int port = 9670; //port to xbee wi-fi
message = message+";\n";
udp.send( message, ip, port );
}
void receive( byte[] data, String ip, int port ) {
int len = data.length;
byte[] message = subset(data, 0, len);
for( int i = 0; i<len; i++ ){
if (message[i] == 0) {
if (message[i + 1] == 7)
println (message[i + 2] + " " + message[i + 3]+ " " + message[i + 4]+ " " + message[i + 5]+ " " + message[i + 6]+ " " + message[i + 7] );
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment