In-browser Arduino interaction with HTML and JavaScript

ArduGate is an open-source web gateway software I am developing, for interfacing Arduino with JavaScript. It is actually made up of a serial-to-HTTP gateway (based on my miniweb project), some JavaScript routines performing communication with AJAX and an agent sketch running on Arduino.
It makes interaction between in-browser JavaScript and Arduino possible, and thus makes developing a up-stream application for Arduino that runs on any platform with a browser a lot easier.

You can find more information and download it on the project homepage.
Right now access to following Arduino APIs/objects are implemented:

  • pinMode
  • digitalRead/digitalWrite
  • analogRead/analogWrite
  • EEPROM (read/write)
  • Servo (attach/detach/read/write)

The key concept is using JavaScript inside the web browser to interact with Arduino. Here are several demostrating JavaScript code clips. You will find the code similar to that in an ordinary Arduino sketch.

Accessing EEPROM

/* write a byte of 0x80 to EEPROM at address 0xA0*/
var address = 0xA0;
var data = 0x80;
if (EEPROM.write(addr, data))
{
	/* success, now read back from EEPROM */
	data = EEPROM.read(addr);
	alert(data);
}

Controlling a servo

/* create servo object */
var myServo = new Servo();
/* attach servo to pin 3 */
myServo.attach(3);
/* set servo angle */
myServo.write(90);
/* get servo angle */
var angle = myServo.read();
alert("Current angle is " + angle);

it looks pretty cool and I looking forward to seeing it released

Very usefull, next step might even be an IDE in Javascript?

Then Arduino would become somewhat on par with the MBED development system in the cloud.

EEPROM access and Servo control are just added.

I2C access is added.