Git Product home page Git Product logo

arest.js's Introduction

aREST.js

aREST.js is a JavaScript library that was made to easily control your projects running aREST. It can be used with a simple web browser without Node.js. It works with all the aREST projects using HTTP communication, for example using Arduino with the CC3000 WiFi chip, the Ethernet shield, or the WiFi shield. It also works with the ESP8266 WiFi chip.

Installation

You can simply embed aREST.js in an HTML page by including the file from the CDN:

https://cdn.rawgit.com/marcoschwartz/aREST.js/master/aREST.js

Note that you also need to include jQuery & AjaxQ.

Usage

You can simply create a new device in the JavaScript part of your project by giving the IP address of your aREST board as an argument:

var device = new Device(ip_address);

Getting Started

Let's see a simple example. We are going to create a new aREST device, set pin number 6 to an output, and then turn pin 6 to a HIGH state.

You first need to include the required libraries in your HTML page:

<script type="text/javascript" src="https://code.jquery.com/jquery-2.1.4.min.js"></script>
<script type="text/javascript" src="https://cdn.rawgit.com/Foliotek/AjaxQ/master/ajaxq.js"></script>
<script type="text/javascript" src="https://cdn.rawgit.com/marcoschwartz/aREST.js/master/aREST.js"></script>
<script type="text/javascript" src="script.js"></script>

Then, inside the script.js file, use this code to create a new aREST device (modify the IP address with the one from your device), set pin number 6 to an output, and then turn pin 6 to a HIGH state:

// Create device
var device = new Device("192.168.1.101");

// Set pin 6 to output
device.pinMode(6, "OUTPUT");

// Put set pin 6 to HIGH
device.digitalWrite(6, 1);

I also invite you to check the demo.html example that is given with this GitHub repository.

Supported Commands

This are all the commands that are currently supported by the library, that you can call on Device instance:

  • pinMode
  • digitalWrite
  • digitalRead
  • analogWrite
  • analogRead
  • getVariable
  • callFunction

arest.js's People

Contributors

marcoschwartz avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.