Created
May 27, 2013 03:08
-
-
Save moxuse/5654995 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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