Go Down

Topic: In-browser Arduino interaction with HTML and JavaScript (Read 1 time) previous topic - next topic

May 18, 2012, 11:20 am Last Edit: May 21, 2012, 11:32 am by stanleyhuang Reason: 1
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
Code: [Select]
/* 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
Code: [Select]
/* 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);
My Arduino blog: http://arduinodev.com/blog

TonyD

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

robtillaart


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.
Rob Tillaart

Nederlandse sectie - http://arduino.cc/forum/index.php/board,77.0.html -
(Please do not PM for private consultancy)

EEPROM access and Servo control are just added.
My Arduino blog: http://arduinodev.com/blog

My Arduino blog: http://arduinodev.com/blog

Go Up