Javascript PONG in webserver on Ethernet Shield


I just made this sketch to show that you can use JavaScript in your embedded webpage on the Arduino. I didn’t use an SD card, or an external link. I’ve just put the pong game made by Joe Nesbella in an html page and then into to sketch.

It’s just a proof of concept.

the sktech is about 10856 bytes and doesn’t use much of SDRAM thanks to avr/pgmspace.h (a buffer of 110 bytes)

So now you know you can all make fancy webpages for your pin toggling web paged Arduinos.

javascriptpong.pde (10.9 KB)

Yes, you should have no problem with JavaScript because it is run in the browser, not off the server. The server just serves it up like it would HTML. Your only issue is with space.

can you share your code please ?

Yes I can. I've already attached the sketch in the first post, so you can download it. Remember that this only is a simple webserver, that feeds you a webpage with pong. It doesn't use the arduino to handle buttons.

Don't forget to change IP

// Enter a MAC address and IP address for your controller below. // The IP address will be dependent on your local network: byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED }; byte ip[] = { 192,168,1, 117 };

Good thank you.

It don't work, is it for w5100 or enc28j60 ?

Well, I made this for the Arduino Ethernet shield or Arduino Ethernet with the Wiznet W5100 ethernet chip. It also was made this for Arduino 0.22, maybe you already have Arduino 1.0?

Are you able to compile the sketch?

My shield is a cheap version from china, i use the ENC28J60. I can upload without any errors but when i try the webpage it do not work.

Well, I do know that:

#include <SPI.h>
#include <Ethernet.h>

are for the Wiznet W5100 ethernet chip, maybe you need to adapt these to get the right libraries for the ENC28J60

this page might help you:

you’ll have to download that library and use it instead of the one included in Arduino.