Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

hoodja/duino

Open more actions menu
 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

36 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

duino

A framework for working with Arduinos in node.js

arduino

install

npm install duino

usage

var arduino = require('duino'),
    board = new arduino.Board();

var led = new arduino.Led({
  board: board,
  pin: 13
});

led.blink();

what ಠ_ಠ

The way this works is simple (in theory, not in practice). The Arduino listens for low-level signals over a serial port, while we abstract all of the logic on the Node side.

  1. Plug in your Arduino
  2. Upload the C code at ./src/du.ino to it
  3. Write a simple duino script
  4. ?????
  5. Profit!

libraries

##board

Right now, the board library will attempt to autodiscover the Arduino. I'm going to make it configurable, don't worry.

var board = new arduino.Board();

The board object is an EventEmitter. You can listen for connected, data and message. Data is a raw output from the serial port. Message is emitted after a newline is encountered and is just a vanity funtion.

board.on('connected', function(){
  console.log('Connected!');
});

board.on('message', function(m){
  console.log(m);
}

###board.serial

Low-level access to the serial connection to the board

###board.write(msg)

Write a message to the board using predefined delimiters

###board.pinMode(pin, mode)

Set the mode for a pin. mode is either 'in' or 'out'

###board.digitalWrite(pin, val)

Write one of the following to a pin:

####board.HIGH and board.LOW

Constants for use in low-level digital writes

##led

var led = new arduino.Led({
  board: board,
  pin: 13
});

###led.on()

Turn the LED on

###led.off()

Turn the LED off

###led.blink(interval)

Blink the LED at interval ms. Defaults to 1000

##button

##servo

##motor

##piezo

##potentiometer

protocol

Each message sent to the Arduino board by the board class has 8 bytes.

A full message looks like this:

!011301.

! Start 01 Command (digitalWrite) 13 Pin number 01 Value (high) . Stop

I was drunk. It works.

##command

What is implemented right now:

  • 00 pinMode
  • 01 digitalWrite

##pin

I haven't tested analog pins yet. Soon. Digital pins 0-13 tested.

##value

  • 00 low
  • 01 high

license

(The MIT License)

Copyright (c) 2011 Cam Pedersen cam@onswipe.com

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the 'Software'), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

About

Arduino framework for node.js

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published
Morty Proxy This is a proxified and sanitized view of the page, visit original site.