Skip to content
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
examples removed unused servo state information Feb 12, 2014
includes New license under MIT Sep 21, 2015
src
.gitignore Initial commit Oct 27, 2013
LICENSE
Makefile
README.md Update README.md Oct 27, 2013

README.md

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!

You can’t perform that action at this time.