A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://www.npmjs.com/package/arduino-firmata below:

arduino-firmata - npm

arduino-firmata

Arduino Firmata protocol (http://firmata.org) implementation on Node.js.

Install
% npm install arduino-firmata
Requirements Usage Samples Setup

Connect

var ArduinoFirmata = require('arduino-firmata');

var arduino = new ArduinoFirmata();

 

arduino.connect(); 

arduino.connect('/dev/tty.usb-device-name');

 

arduino.on('connect', function(){

 

  console.log("board version"+arduino.boardVersion);

  

 

});

Reset

Close

I/O

Digital Write

arduino.digitalWrite(13, true, callback);

arduino.digitalWrite(13, false, callback);

Digital Read

arduino.pinMode(7, ArduinoFirmata.INPUT);

console.log( arduino.digitalRead(7) ); 

Digital Read (event)

arduino.pinMode(7, ArduinoFirmata.INPUT);

 

arduino.on('digitalChange', function(e){

  console.log("pin" + e.pin + " : " + e.old_value + " -> " + e.value);

});

Analog Write (PWM)

setInterval(function(){
  var an = Math.random()*255; // 0 ~ 255
  arduino.analogWrite(9, an, callback);
}, 100);

Analog Read

console.log( arduino.analogRead(0) ); 

Analog Read (event)

arduino.on('analogChange', function(e){

  console.log("pin" + e.pin + " : " + e.old_value + " -> " + e.value);

});

Servo Motor

setInterval(function(){

  var angle = Math.random()*180; 

  arduino.servoWrite(11, angle, callback);

}, 1000);

Sysex

Send

arduino.sysex(0x01, [13, 5, 2], callback);  

Register Sysex Event

arduino.on('sysex', function(e){

  console.log("command : " + e.command);

  console.log(e.data);

});

Develop
% npm install
% npm run build
# or
% npm run watch
Test Install SysexLedBlinkFirmata into Arduino Run Test
% npm test
Contributing
  1. Fork it
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create new Pull Request

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4