Sign Up for Free

RunKit +

Try any Node.js package right in your browser

This is a playground to test code. It runs a full Node.js environment and already has all of npm’s 400,000 packages pre-installed, including arscripter with all npm packages installed. Try it out:

var arscripter = require("arscripter")

This service is provided by RunKit and is not affiliated with npm, Inc or the package authors.

arscripter v0.6.5

A web-based approach to rapid Arduino prototyping

arscripter

A web-based approach to rapid Arduino prototyping. Program your Arduino board straight from the browser using JavaScript and GUI controls.

Requirements

Installation

npm install -g arscripter

Usage

  1. Connect Arduino via USB
  2. Execute arscripter
  3. Navigate to http://localhost:8080 in web browser
  • Toggle the mode and/or value of a pin by clicking on the appropriate label
  • PWM values can be set via the adjacent slider
  • Analog values can be viewed in the adjacent graph

API

  • loop(ms, handler())
    Execute the handler function every ms milliseconds

  • display(msg)
    Print msg to the output pane

  • getPinValue(pin)
    Returns the current value of the given pin
  • setPinValue(pin, value)
    Write a value to a given pin
  • toggleDigitalValue(pin)
    Write the opposite of the current value of a given pin
  • getPinMode(pin)
    Returns the current mode of the given pin
  • setPinMode(pin, mode)
    Set the mode of a given pin, one of the possible pin modes (see below)

Pin Modes

  • 0: Input
  • 1: Output
  • 2: Analog
  • 3: PWM

Basic Script

var pin = 13;
setPinMode(pin,1);

loop(1000, function() {  
  toggleDigitalValue(pin);

  setTimeout(function() {
    display('Pin ' + pin + ' value: ' + getPinValue(pin) + '\n');
  }, 10);
  
});

Notes

  • The first analog pin is reached at the number following the last digital pin (e.g. the last digital pin on the Uno is pin 13, so A0 is pin 14).

Metadata

RunKit is a free, in-browser JavaScript dev environment for prototyping Node.js code, with every npm package installed. Sign up to share your code.
Sign Up for Free