arduino-firmata
Arduino Firmata protocol (http://firmata.org) implementation on Node.js.
- Firmata is a protocol to controll Arduino from software on PC.
- You can embed Arduino code into Node.js application.
- Support sharing an Arduino between multiple processes.
- https://github.com/shokai/node-arduino-firmata
- https://npmjs.org/package/arduino-firmata
Install
% npm install arduino-firmata
Requirements
- Arduino (http://arduino.cc)
- testing with
- Arduino Diecimila
- Arduino Duemillanove
- Arduino UNO
- Arduino Leonardo
- Arduino Micro
- Seeduino v2
- testing with
- Arduino Standard Firmata v2.2
- Arduino IDE -> [File] -> [Examples] -> [Firmata] -> [StandardFirmata]
Usage
Samples
Setup
Connect
var ArduinoFirmata = ;var arduino = ; arduino; // use default arduinoarduino; arduino;
Reset
arduino;
Close
arduino;
I/O
Digital Write
arduino;arduino;
Digital Read
arduino;console; // => true/false
Digital Read (event)
arduino; arduino;
Analog Write (PWM)
setInterval(function(){
var an = Math.random()*255; // 0 ~ 255
arduino.analogWrite(9, an, callback);
}, 100);
Analog Read
console; // => 0 ~ 1023
Analog Read (event)
arduino;
Servo Motor
;
Sysex
- http://firmata.org/wiki/V2.1ProtocolDetails#Sysex_Message_Format
- https://github.com/shokai/node-arduino-firmata/tree/master/samples/sysex
Send
arduino; // command, data_array, callback
Register Sysex Event
arduino;
Develop
% npm install
% npm run build
# or
% npm run watch
Test
Install SysexLedBlinkFirmata into Arduino
Run Test
% npm test
Contributing
- Fork it
- Create your feature branch (
git checkout -b my-new-feature
) - Commit your changes (
git commit -am 'Add some feature'
) - Push to the branch (
git push origin my-new-feature
) - Create new Pull Request