Home > Uncategorized > C library for Arduino – Preview

C library for Arduino – Preview

November 1st, 2009

I’m working on a C library for Arduino hardware. The goal is to make it just as easy as the Arduino programming language but in plain standard C. The Arduino language is halfway between C and C++. While Arduino hardware uses the same Atmel atmega168 and atmega328 that I’ve come to love, the software does not allow me to code in standard C. It prevents one from being able to borrow all of the standard C and assembly (easily) that is out there for AVR micros. More importantly, it means that I have to load up a java IDE instead of just using the GNU command line tools such as avr-gcc, avr-libc, and make. By using the Arduino hardware, we get access to mass produced hardware and the Arduino bootloader. The Arduino hardware is handy because we can program it over the same interface as we use for printf() debugging. Also, since it can get its power over USB, it bundles up lots of the initial hurdles of getting started with micros.

Already the library supports:
serial – printf(), getchar(), etc
standard I/O – easily make pins input or output, set pins high and low
pwm – LED brightness, motor control
pwm servo – control RC servos
adc – read analog values

Here is a preview reading analog in with the ADC and controling the brightness of an LED using PWM:

I’m still working on making the wiki page match this blog and storing the code in SVN. For an early preview, check out http://tinkerish.com/wiki/.

mike Uncategorized

  1. hesa
    January 28th, 2010 at 12:30 | #1

    Just started to work on making libarduino as a static lib and a makefile for inclusion on projects using libarduino

    Will get back when I am getting closer

  2. January 29th, 2010 at 14:34 | #2

    Awesome! I’m anxious to find out if the linker is smart enough to only pull in the functions that are used. In the old days (last time I checked), you had to separate things into groups of .c files that get built into separate .o files. It was smart enough to only pull in the things from the static library that came from a particular .o. It is the time that it would take to test and check this that has prevented me from moving from the #define method.

  3. aalm
    February 2nd, 2010 at 09:21 | #3

    Good start! My first addition for libarduino was:

    int check_serial(void)
    {
    if (uart_writeptr == uart_readptr)
    return 0;
    else return 1;
    }

  4. hesa
    February 3rd, 2010 at 05:11 | #4

    I think am finished. Well, for some kind of demo version at least.

    Read more about it here:
    http://www.sandklef.com/hesa/index.php/2010/01/29/libarduino-hacked-it-a-bit/

    Basically, I have restructured the dir layout a bit and added a Makefile (for inclusion).

  5. hesa
    February 3rd, 2010 at 05:13 | #5

    @mike

    as far as the pulling things from .o files, I have done nada. But I am willing to :)

  1. May 3rd, 2010 at 18:53 | #1
You must be logged in to post a comment.