Warning: Use of undefined constant DB_CHARSET - assumed 'DB_CHARSET' (this will throw an Error in a future version of PHP) in /home/forge/floriansweb.com/wp-content/plugins/wordpress-flickr-manager/FlickrManager.php on line 109
Arduino + Wishield + LED Matrix = a lot of fun! | Floriansweb

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

socketapp.c

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

main

void loop() {
  WiFi.run();
  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));
    matrix.send();
}

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

5 Comments

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

Hi,
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