Skip to end of metadata
Go to start of metadata

You are viewing an old version of this content. View the current version.

Compare with Current View Version History

Version 1 Next »

This page presents the most basic programs that should first be tried out by every program when first getting their hands on a CrcDuino.

Minimal program

The following details the code lines that should be minimally used in every program that uses CrcLIb.

#include <CrcLib.h>

using namespace Crc;

void setup()
{
    CrcLib::Initialize();
}

void loop()
{
    CrcLib::Update();
}

//Lines starting with 2 slashes won't be compiled; they are comments.

/*This is a way 
to comment multiple lines of code */

Let's go through this line by line to figure out exactly why all this is here:

#include <CrcLib.h>

This is how Arduino IDE loads the CrcLib when compiling the code, allowing the use use its functions. This will of course only work if the library as first been properly installed as detailed here.


using namespace Crc;

The namespace "Crc" is where all of CrcLib lives. If this line is included at the beginning of the code, Crc:: won’t have to be written in front of every CrcLib function call.


void setup()
{
  //The code executed once at power-up
}

The "setup" function is Arduino-specific. All the lines in the brackets right after it will be run only once, when the CrcDuino is powered up.


CrcLib::Initialize();

This call must be made in order to properly set up everything in order for CrcLib functions to be executed properly.

void loop()
{
  //The code repeated as long as the board is powered up.
}

The "loop" function is Arduino-specific and will be run repeatedly for as long as your Arduino is running.


CrcLib::Update();

This call must be made in order to properly update the library on every loop.

Using the Arduino IDE serial monitor

The Arduino serial monitor is a very useful tool that every programmer should be able to use when debugging their CrcDuino program. It allows the the CrcDuino to print messages to a computer screen. It can be used, for example, to confirm that a sensor state is read correctly by the CrcDuino.

  • No labels

0 Comments

You are not logged in. Any changes you make will be marked as anonymous. You may want to Log In if you already have an account.