Git Product home page Git Product logo

firmatac's Introduction

FirmataC

This is a simple and lightweigh C library to communicate with Firmata devices such as Arduino.

This library implements Firmata V2.3.

Example

Here is the implementation of Arduino blinking led tutorial using FirmataC.

#include "firmata.h"

int             main()
{
  t_firmata     *firmata;
  int           i = 0;
  
  //init Firmata
  firmata = firmata_new("/dev/ttyACM0");
  //Wait until device is up 
  while(!firmata->isReady)
    firmata_pull(firmata);
  //set pin 13 (led on most arduino) to out  
  firmata_pinMode(firmata, 13, MODE_OUTPUT); 
  while (1)
    {
      sleep(1);
      if (i++ % 2)
        firmata_digitalWrite(firmata, 13, HIGH); //light led
      else
        firmata_digitalWrite(firmata, 13, LOW);	//unlight led 
    }
}

Reference

t_firmata       *firmata_new(char *name)
  • name: path to device, usually "/dev/ttyACM0"
int             firmata_pinMode(t_firmata *firmata, int pin, int mode)
  • pin: #pin
  • mode: pinMode can be: MODE_INPUT, MODE_OUTPUT, MODE_SERVO, MODE_PWM, MODE_ANALOG, MODE_SHIFT, MODE_I2C
int             firmata_digitalWrite(t_firmata *firmata, int pin, int value)
  • pin: #pin
  • value: can be HIGH or LOW
int             firmata_analogWrite(t_firmata *firmata, int pin, int value)
  • pin: #pin
  • value: #value
int             firmata_pull(t_firmata *firmata)

Pull input. To read values about captor refer to firmata->pins[nbPin] (described in "includes/firmata.h").

For more information see the Arduino documentation.

License

See License file included in sources.

Thanks

Special thanks to Paul Stoffregen for the Firmata GUI-friendly that helped much!

firmatac's People

Contributors

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