Arduino + Wishield + LED Matrix = a lot of fun!


extern char buffer[20];
static int handle_connection(struct socket_app_state *s)
  PSOCK_READTO(&s->p, '\n');
  memset(s->inputbuffer, 0x00, sizeof(s->inputbuffer));


void loop() {;
  if(strncmp(buffer, "SET LED", 7) == 0) {
    substr(positionX, buffer, 8,1);
    substr(positionY, buffer, 10,1);
    substr(color, buffer, 12,3);
    matrix.set(atoi(positionX),atoi(positionY), atoi(color));

Sending to the socket server (Cocoa, NSStream)

-(void)sendData:(NSString *)string {
	NSString *stringWithEnding = [NSString stringWithFormat:@"%@\n", string];
	const uint8_t * rawstring = (const uint8_t *)[stringWithEnding UTF8String];
	[oStream write:rawstring maxLength:strlen(rawstring)];

Bildschirmfoto 2009-10-21 um 21.58.01

Sourcecode of the Arduino Socket Server

Sourcecode of the Cocoa Socket Client

Sourcecode of ’simple‘ pong

led matrix protocol:

SET LED x:y:color


GregEigstiOktober 18th, 2009 at 9:49 pm

Nice job!

jhmckeeverJuni 23rd, 2010 at 8:30 pm

Great work. How do you avoid the situation where sending colour 0x25 (‚%‘) causes the matrix to go into ‚command‘ mode?

FelixDezember 13th, 2010 at 9:13 am

Sorry to disturb you!
I use MAC mini to run your code to connect Arduino with WiShield 2.0!
I try both MAC mini to connect router and not connect router.
But there is no connection!
Could you give me some suggestion?Please!
I really need your help.
Any advices will be appreciated!Thanks in advance.

franckJanuar 12th, 2011 at 9:51 am

hello, nice project but i don’t arrive to do it, i have this error:
socketapp.c: In function ‚handle_connection‘:
socketapp.c:112: error: ‚amp‘ undeclared (first use in this function)

can you help me please

felipeMai 21st, 2011 at 6:34 am

I did not understand a thing.

Every time the arduino receives the data and closes the socket. In your application you are connecting when requested and not when it will send the data, then how could you send? Because if you sent one time he closed the socket

Leave a comment

Your comment