A Note on Developing in Standard C vs Arduino

Where I illustrate the differences between developing code using Standard C vs using the Arduino Framework.

Introduction

The goal of the AVR C course content is to demonstrate how you are able to develop code in C without the Arduino Framework. This note is intended to show specifically, the differences in code development between the two. I don’t believe one is intrinsically better than the other as I believe, each one has strong positive traits related to its goals.

Arduino IDE to Standard C Translation

Here is a table, where I attempt to show the differences and similarities between using the Arduino Framework and the Standard C approach.

Approach Arduino Standard C
Interface GUI Command line
Language C/C++/Arduino Classes ANSI C
Tool Chain All self-contained in Arduino IDE Must be installed separately, easy in Linux, can be difficult in Windows.
Compile Command Checkmark in GUI, Verify make
Upload Right Arrow in GUI, Upload make flash
Program Development Called a sketch and can be multi-file. Is file-based, can be multi-file
Files filename must ends with .ino filename must end with .c
Folder files must be in current folder or Library files must be in current folder or Library
Libraries Uses Libraries for specific functionality Uses Libraries for specific functionality
Library Content Broad and diverse set of Libraries, rich with 3rd party devices Narrow and well-defined Library aimed at Standard C
Principal Library Arduino Board AVR-libc
Library Documentation Language Reference avr-libc
Arduino Compatibility N/A already Arduino AVR_C

File Template

Arduino

filename.ino

void setup() {
  // put your setup code here, to run once:

}

void loop() {
  // put your main code here, to run repeatedly:

}

Standard C

filename.c

/* Document what this program does, include req'd hardware changes
*/

/* Put your #includes here */
#include <stdio.h>
#include <stdlib.h>


/* Put your global variables here */

/* Main - is the function which C will look for to run at initialization*/ 
int main() {
/* initialize code goes here, similar to setup in the Arduino*/

// while(1) loop routine runs over and over again forever:
    while(1) {
        // this is the primary code section to execute
    }
    return(0); /* Required for strict C implementation
}

Comments powered by Talkyard.