Giter Site home page Giter Site logo

lua-firmata's Introduction

Arduino Firmata for Lua

This is a porting of the Processing library for Firmata (which, by the way, needs modifications to work with Processing 2.0, but this is another story). The arduino.lua file is the library itself, with code for reading and writing digital and analog values to and from an Arduino running a compatible version of Firmata; the code has been tested with Arduino Uno and Firmata 2.3 (distributed with Arduino IDE 1.0.5). The example simply blinks the test led (pin 13) every two seconds, and reads values from a sensor connected to the first analog pin (A0) when it changes the led status.

A coroutine scheduler is used to wait for data coming from the serial port and sending commands at the same time (the dispatcher can be found here); a numeric library is needed to perform bitwise operations (the source code can be found here). I added the code for these libraries here as it is easier to directly test it, but you can substitute them if you want. There are probably faster and better bitwise libraries, written in C, but I didn't want to have to cross-compile C code when testing on different hardware (e.g., OpenWRT). The same stands for the scheduler: you can write your own and use it instead of the one I include here.

Two important observations:

  • the example slightly changes when run on Carambola, which is a device running OpenWRT, due to differences in how the gettimeofday system call is handled
  • please, forgive any programming error: this is my first program written in Lua, so there may be mistakes well hidden somewhere...

lua-firmata's People

Contributors

sivieri avatar

Watchers

 avatar  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.