Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

Learn the basics of programming using C/C++.

...

The code is written in, compiled and finally downloaded in the micro-controller using an Integrated Development Environment. Although the CRC Robotics Competition participants are free to use whatever Arduino compatible IDE, we strongly recommend (and only support) the official desktop-based Arduino IDE.

...

The lines of code are written using C/C++.

...

Your IDE then uses a compiler to transform your C/C++ lines of code into micro-controller instructions.

...

Info

In Arduino IDE, compiling is known as verifying and code is written in .ino files.

Info

Once the upload is done,

...

the CrcDuino reboots and then starts executing

...

the code. It will run whatever is written in the void setup() part of

...

the .ino file program once, and then it will execute over and over again

...

whatever’s written in the void loop() part.

...

You repeat step 2 to 5 until your robot does what you want it to do!

Primitives

Computers can natively only perform operations on some data types. These are integer and floating point (float) numbers. Those are called primitives. Integers are further divided in two classes, signed and unsigned. Signed numbers can represent negative as well as positive integers (signed = with a sign, get it?), while unsigned numbers can’t.

...

  • float which can hold values from 10-38 to 1038 with a precision of around 7 digits;

  • double which can hold values from 10-308 to 10308 with a precision of around 16 digits.

...

In a more understandable format:

Type

Also known as in Arduino

Negatives?

Size (bit)

Minimum

Maximum

uint8_t

unsigned char or byte

No

8

0

28 - 1 (255)

int8_t

char

Yes

8

-27 (-128)

27 - 1 (127)

uint16_t

unsigned int or word

No

16

0

216 - 1 (6553565 535)

int16_t

int

Yes

16

-215 (-3276832 768)

215 - 1 (3276732 767)

uint32_t

unsigned long

No

32

0

232 - 1 (42949672954 294 967 295)

int32_t

long

Yes

32

-231 (-21474836482 147 483 648)

231 - 1 (21474836472 147 483 647)

uint64_t

unsigned long long

No

64

0

264 - 1 (3.68935 × 1019)

int64_t

long long

Yes

64

-263 (-9.22337 × 1018)

263 - 1 (9.22337 × 1018)

Info

When starting, you can use the “Also known as in Arduino” nomenclature, but you should try to understand and use the official integer nomenclature.

In the official nomenclature, the size of every int type is explicitely defined and the same on every platform, whereas an “int” might be 16bit on a micro-controller model and 32bit on another one. Using this nomenclature is a nice habit since it makes your code more portable; meaning that it will have the same execution characteristic on different platforms.